Skip to content

Commit

Permalink
Make the $status of the last command available in %interactive-loop.
Browse files Browse the repository at this point in the history
The variable is called $status for cultural compatibility with rc and
direct compatibility with $bqstatus.
  • Loading branch information
jpco committed Dec 1, 2023
1 parent 624829a commit 2c31755
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions initial.es
Original file line number Diff line number Diff line change
Expand Up @@ -624,17 +624,17 @@ if {~ <=$&primitives execfailure} {fn-%exec-failure = $&execfailure}
# to print ``break outside of loop'' errors.
#
# The parsed code is executed only if it is non-empty, because otherwise
# result gets set to zero when it should not be.
# status gets set to zero when it should not be.
fn-%parse = $&parse
fn-%batch-loop = $&batchloop
fn-%is-interactive = $&isinteractive
fn %interactive-loop {
let (result = <=true) {
local (status = <=true) {
catch @ e type msg {
if {~ $e eof} {
return $result
return $status
} {~ $e exit} {
throw $e $type $msg
} {~ $e error} {
Expand All @@ -655,7 +655,7 @@ fn %interactive-loop {
}
let (code = <={%parse $prompt}) {
if {!~ $#code 0} {
result = <={$fn-%dispatch $code}
status = <={$fn-%dispatch $code}
}
}
}
Expand Down Expand Up @@ -739,12 +739,12 @@ max-eval-depth = 640
# is for the parent process. pid is not exported so that even if it
# is set explicitly, the one for a child shell will be correct.
# Signals are not exported, but are inherited, so $signals will be
# initialized properly in child shells. bqstatus is not exported
# because it's almost certainly unrelated to what a child process
# is does. fn-%dispatch is really only important to the current
# interpreter loop.
# initialized properly in child shells. status and bqstatus are not
# exported because it's almost certainly unrelated to what a child process
# does. fn-%dispatch is really only important to the current interpreter
# loop.

noexport = noexport pid signals apid bqstatus fn-%dispatch path home matchexpr
noexport = noexport pid signals apid status bqstatus fn-%dispatch path home matchexpr


#
Expand Down

0 comments on commit 2c31755

Please sign in to comment.