mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix side effect to exit status of DEBUG trap in comsub
This fixes the following: trap ':' DEBUG r=$(exit 123) echo $? # Expected 123, but actually 0. Thanks to Koichi Nakashima for the report and reproducer. src/cmd/ksh93/sh/fault.c: sh_trap(): - Restore the saved current exit status (exitval) for all traps. Do not except the DEBUG trap from doing that. I've no idea why this exception was made, but it's not correct. src/cmd/ksh93/tests/basic.sh: - Add tests. Makes progress on: https://github.com/ksh93/ksh/issues/155
This commit is contained in:
parent
5ee290c7a8
commit
d00b4b39f6
4 changed files with 19 additions and 2 deletions
|
@ -734,5 +734,17 @@ got=$(eval 'x=${ for i in test; do case $i in test) true;; esac; done; }' 2>&1)
|
|||
got=$(eval 'x=`for i in test; do case $i in test) true;; esac; done`' 2>&1) \
|
||||
|| err_exit "case in a for loop inside a \`comsub\` caused syntax error (got $(printf %q "$got"))"
|
||||
|
||||
# ======
|
||||
# The DEBUG trap had side effects on the exit status
|
||||
# https://github.com/ksh93/ksh/issues/155 (#4)
|
||||
trap ':' DEBUG
|
||||
(exit 123)
|
||||
(((e=$?)==123)) || err_exit "DEBUG trap run in subshell affects exit status (expected 123, got $e)"
|
||||
r=$(exit 123)
|
||||
(((e=$?)==123)) || err_exit "DEBUG trap run in \$(comsub) affects exit status (expected 123, got $e)"
|
||||
r=`exit 123`
|
||||
(((e=$?)==123)) || err_exit "DEBUG trap run in \`comsub\` affects exit status (expected 123, got $e)"
|
||||
trap - DEBUG
|
||||
|
||||
# ======
|
||||
exit $((Errors<125?Errors:125))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue