Op 23-12-16 om 00:30 schreef Martijn Dekker:
> On busybox 1.26.0, 'eval' returns status 0 even if there is a syntax error.
>
> $ ( eval '(' ) && echo false positive
> ./ash: eval: syntax error: unexpected end of file (expecting ")")
> false positive
>
> This behaviour does not occur in 1.25.1.
The issue turns out to be more general than that: on an interactive
shell, or when invoking a script using Busybox 1.26.0 ash, the exit
status is 0 on a parsing error as well.
$ cat >test.sh <<EOF
)
EOF
$ ./ash test.sh && echo 'false positive'
test.sh: line 1: syntax error: unexpected ")"
false positive
I believe the patch below fixes the bug. It simply sets the global
exitstatus variable to 2 when raising a syntax error. This makes ash's
behaviour consistent with that of 1.25.1 and previous versions.
Thanks,
- M.
diff --git a/shell/ash.c b/shell/ash.c
index 430e42a..af32cea 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -1294,6 +1294,7 @@ static void raise_error_syntax(const char *) NORETURN;
static void
raise_error_syntax(const char *msg)
{
+ exitstatus = 2;
ash_msg_and_raise_error("syntax error: %s", msg);
/* NOTREACHED */
}
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox