mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix restoring DEBUG trap upon exiting virtual subshell
This trap failed to be restored correctly when being trapped in a subshell, causing corruption or a crash when restoring the parent shell environment's trap upon leaving the subshell. Thanks to Koichi Nakashima for the report and reproducer. src/cmd/ksh93/sh/fault.c: sh_sigreset(): - Fix an off-by-one error in the loop that restores the pseudosignal traps. src/cmd/ksh93/tests/basic.sh: - Test overwriting the main shell trap in a subshell for all pseudosignals. Makes progress on: https://github.com/ksh93/ksh/issues/155
This commit is contained in:
parent
ac8e702ef2
commit
2a835a2d8a
4 changed files with 23 additions and 2 deletions
|
@ -744,6 +744,22 @@ 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 crashed when re-trapping inside a subshell
|
||||
# https://github.com/ksh93/ksh/issues/155 (#2)
|
||||
exp=$'trap -- \': main\' EXIT\ntrap -- \': main\' ERR\ntrap -- \': main\' KEYBD\ntrap -- \': main\' DEBUG'
|
||||
got=$({ "$SHELL" -c '
|
||||
PATH=/dev/null
|
||||
for sig in EXIT ERR KEYBD DEBUG
|
||||
do trap ": main" $sig
|
||||
( trap ": LEAK : $sig" $sig )
|
||||
trap
|
||||
trap - "$sig"
|
||||
done
|
||||
'; } 2>&1)
|
||||
((!(e = $?))) && [[ $got == "$exp" ]] || err_exit 'Pseudosignal trap failed when re-trapping in subshell' \
|
||||
"(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got"))"
|
||||
|
||||
# ======
|
||||
# The DEBUG trap had side effects on the exit status
|
||||
# https://github.com/ksh93/ksh/issues/155 (#4)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue