Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions doc/es.1
Original file line number Diff line number Diff line change
Expand Up @@ -2388,8 +2388,8 @@ shell scripts if the kernel does not.
.TP
.Cr "%exit-on-false \fIcmd\fP"
Runs the command, and exits if any command
(except those executing as the tests of conditional statements)
returns a non-zero status.
(except assignments, or those executing as the tests of conditional
statements) returns a non-zero status.
(This function is used in the definition of
.Cr %dispatch
when the shell is invoked with the
Expand Down Expand Up @@ -2901,8 +2901,8 @@ starts with a dash
.Rc ( - ).
.TP
.Cr \-e
Exit if any command (except those executing as the tests of
conditional statements) returns a non-zero status.
Exit if any command (except assignments, or those executing as the
tests of conditional statements) returns a non-zero status.
.TP
.Cr \-v
Echo all input to standard error.
Expand Down
5 changes: 4 additions & 1 deletion eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "es.h"

unsigned long evaldepth = 0, maxevaldepth = MAXmaxevaldepth;
static Boolean did_assign = FALSE;

static Noreturn failexec(char *file, List *args) {
List *fn;
Expand Down Expand Up @@ -76,6 +77,7 @@ static List *assign(Tree *varform, Tree *valueform0, Binding *binding0) {
}

RefEnd4(values, vars, binding, valueform);
did_assign = TRUE;
RefReturn(result);
}

Expand Down Expand Up @@ -378,6 +380,7 @@ extern List *eval(List *list0, Binding *binding0, int flags) {
return ltrue;
}
assert(list->term != NULL);
did_assign = FALSE;

if ((cp = getclosure(list->term)) != NULL) {
switch (cp->tree->kind) {
Expand Down Expand Up @@ -478,7 +481,7 @@ extern List *eval(List *list0, Binding *binding0, int flags) {

done:
--evaldepth;
if ((flags & eval_exitonfalse) && !istrue(list))
if ((flags & eval_exitonfalse) && !istrue(list) && !did_assign)
esexit(exitstatus(list));
RefEnd2(funcname, binding);
RefReturn(list);
Expand Down
6 changes: 3 additions & 3 deletions test/tests/option.es
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ test 'es -e' {
'{true; {true; {false; true}}}' false

# assignments
'x = false' false
'fn x {false}' false
'{true; {true; {x = false}; true}}' false
'x = false' true
'fn x {false}' true
'{true; {true; {x = false}; true}}' true
'let (x = false) true' true
'local (x = false) true' true
)) {
Expand Down