Re: BASH_SUBSHELL reset to 0 on EXIT trap in aubshell

2016-10-15 Thread Chet Ramey
On 10/13/16 4:00 AM, Martijn Dekker wrote: > bash resets BASH_SUBSHELL to 0 when executing an EXIT trap, even if the > EXIT trap is executed in a subshell. > > echo $(trap 'echo $BASH_SUBSHELL' EXIT; echo $BASH_SUBSHELL) > Actual output: 1 0 > Expected output: 1 1 This is a reasonable suggestion

Re: BASH_SUBSHELL reset to 0 on EXIT trap in aubshell

2016-10-13 Thread Martijn Dekker
Also, perhaps BASH_SUBSHELL should be a readonly like BASHPID is. - M.

BASH_SUBSHELL reset to 0 on EXIT trap in aubshell

2016-10-13 Thread Martijn Dekker
bash resets BASH_SUBSHELL to 0 when executing an EXIT trap, even if the EXIT trap is executed in a subshell. echo $(trap 'echo $BASH_SUBSHELL' EXIT; echo $BASH_SUBSHELL) Actual output: 1 0 Expected output: 1 1 The same does not happen for a signal trap. echo $(trap 'echo $BASH_SUBSHELL; exit' IN