ash: fix error code regression
No binary (build failed)
—
(log yok)
| @@ -1284,6 +1284,8 @@ ash_msg_and_raise_error(const char *msg, ...) | |
| { | |
| va_list ap; | |
| + | exitstatus = 2; |
| + | |
| va_start(ap, msg); | |
| ash_vmsg_and_raise(EXERROR, msg, ap); | |
| /* NOTREACHED */ | |
| @@ -9588,11 +9590,13 @@ evalcommand(union node *cmd, int flags) | |
| } | |
| if (status) { | |
| + | bail: |
| + | exitstatus = status; |
| + | |
| /* We have a redirection error. */ | |
| if (spclbltin > 0) | |
| raise_exception(EXERROR); | |
| - | bail: |
| - | exitstatus = status; |
| + | |
| goto out; | |
| } | |
| @@ -0,0 +1,4 @@ | |
| + | ./test.sh: line 1: syntax error: unexpected ")" |
| + | Done:2 |
| + | ./exitcode2.tests: line 11: can't open does_not_exist: no such file |
| + | Done:1 |
| @@ -0,0 +1,12 @@ | |
| + | # syntax error should return status 2 |
| + | cat >test.sh <<EOF |
| + | ) |
| + | EOF |
| + | chmod +x test.sh |
| + | $THIS_SH ./test.sh |
| + | echo Done:$? |
| + | rm -f test.sh |
| + | |
| + | # redirection error with special builtin should return status 1 |
| + | (eval cat <does_not_exist) |
| + | echo Done:$? |
| @@ -0,0 +1,4 @@ | |
| + | hush: syntax error: unexpected ) |
| + | Done:2 |
| + | hush: can't open 'does_not_exist': No such file or directory |
| + | Done:1 |
| @@ -0,0 +1,12 @@ | |
| + | # syntax error should return status 2 |
| + | cat >test.sh <<EOF |
| + | ) |
| + | EOF |
| + | chmod +x test.sh |
| + | $THIS_SH ./test.sh |
| + | echo Done:$? |
| + | rm -f test.sh |
| + | |
| + | # redirection error with special builtin should return status 1 |
| + | (eval cat <does_not_exist) |
| + | echo Done:$? |