Skip to content

Commit d370b45

Browse files
committed
FIX: Restore original path when DO of a script fails
fixes: metaeducation/rebol-issues#2374
1 parent 9b8687a commit d370b45

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/mezz/sys-base.r

+5-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ do*: func [
8484
"Date:" select hdr 'date
8585
]
8686

87-
also
87+
set/any 'value try [
8888
; Eval the block or make the module, returned
8989
either mod? [ ; Import the module and set the var
9090
spec: reduce [hdr data do-needs/no-user hdr]
@@ -95,8 +95,10 @@ do*: func [
9595
intern data ; Bind the user script
9696
catch/quit either var [[do/next data var]] [data]
9797
]
98-
; Restore system/script and the dir
99-
all [system/script: :scr dir change-dir dir]
98+
]
99+
; Restore system/script and the dir
100+
all [system/script: :scr dir change-dir dir]
101+
value
100102
]
101103
]
102104

src/tests/units/evaluation-test.r3

+8
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ Rebol [
5454

5555
===end-group===
5656

57+
===start-group=== "do script"
58+
--test-- "script with error"
59+
;@@ https://github.com/rebol/rebol-issues/issues/2374
60+
dir: what-dir
61+
--assert error? do %units/files/error.r3
62+
--assert dir = what-dir
63+
===end-group===
64+
5765
===start-group=== "do function"
5866

5967
--test-- "do-func-1"

0 commit comments

Comments
 (0)