[PATCH] ash: fix error code regression

Ron Yorston rmy at pobox.com
Tue Jan 3 11:20:01 UTC 2017


Denys Vlasenko wrote:
>> --- /dev/null
>> +++ b/shell/ash_test/ash-misc/exitcode2.tests
>> @@ -0,0 +1,13 @@
>> +# syntax error should return status 2
>> +cat >test.sh <<EOF
>> +)
>> +EOF
>> +chmod +x test.sh
>> +./test.sh
>
>Will this run test.sh in _the shell being tested_
>(as opposed to system shell)?

Good question.  When I was working on this I checked that the test
failed without the patch and succeeded afterwards, so experiment
indicates that the shell being tested was used.

Why so?

In tryexec() if execve() initially fails with errno == ENOEXEC (as it will
for a shell script) the code retries the execve() with bb_busybox_exec_path
as the file and "ash" as argv[0].  This is OK because POSIX doesn't
specify *which* shell is invoked in this case.

>I changed the above to "$THIS_SH ./test.sh" to be sure.

That will definitely work, even if tryexec() changes in future.

>Recently test directories for ash and hush were "cross-pollinated"
>to have similarly-named subdirs and tests. Let's try keeping
>them this way.

Ack.

Ron


More information about the busybox mailing list