Exit with the given status for negative halt_error codes (#3660)
halt_error with a negative exit code did not exit with that code. The code collided with the internal status values for null or false output and for no output, so halt_error(-1) exited with 0, or with 1 under --exit-status. Keep the low 8 bits of a negative code, as exit(3) does on POSIX systems, so halt_error(-1) now exits with 255 and halt_error(-2) with 254, the same with or without --exit-status. Under --exit-status this replaces the previous absolute value, so halt_error(-2) used to exit with 2 and halt_error(-255) with 255, and they now exit with 254 and 1.
This commit is contained in:
1 parent
a8e6d5f871
commit
04042494cf
2 files changed
+15
-2
No files matched your search
@@ -471,6 +471,15 @@ elif [ $? -ne 11 ]; then
|
||||
echo "jq halt_error(11) had wrong error code" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
for opt in '' -e; do
|
||||
if $VALGRIND $Q $VG_EXIT0 $JQ $opt -n 'halt_error(-1)'; then
|
||||
echo "jq $opt halt_error(-1) didn't work as expected" 1>&2
|
||||
exit 1
|
||||
elif [ $? -ne 255 ]; then
|
||||
echo "jq $opt halt_error(-1) had wrong error code" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
if [ -n "$($VALGRIND $Q $JQ -n 'halt_error(1)' 2>&1)" ]; then
|
||||
echo "jq halt_error(1) had unexpected output" 1>&2
|
||||
exit 1
|
||||
|
||||
Reference in new issue
Block a user