Skip to content

Commit

Permalink
FIX: Restore original path when DO of a script fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Apr 29, 2019
1 parent 9b8687a commit d370b45
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/mezz/sys-base.r
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ do*: func [
"Date:" select hdr 'date
]

also
set/any 'value try [
; Eval the block or make the module, returned
either mod? [ ; Import the module and set the var
spec: reduce [hdr data do-needs/no-user hdr]
Expand All @@ -95,8 +95,10 @@ do*: func [
intern data ; Bind the user script
catch/quit either var [[do/next data var]] [data]
]
; Restore system/script and the dir
all [system/script: :scr dir change-dir dir]
]
; Restore system/script and the dir
all [system/script: :scr dir change-dir dir]
value
]
]

Expand Down
8 changes: 8 additions & 0 deletions src/tests/units/evaluation-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ Rebol [

===end-group===

===start-group=== "do script"
--test-- "script with error"
;@@ https://github.com/rebol/rebol-issues/issues/2374
dir: what-dir
--assert error? do %units/files/error.r3
--assert dir = what-dir
===end-group===

===start-group=== "do function"

--test-- "do-func-1"
Expand Down

0 comments on commit d370b45

Please sign in to comment.