[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
BASH_SUBSHELL reset to 0 on EXIT trap in aubshell
From: |
Martijn Dekker |
Subject: |
BASH_SUBSHELL reset to 0 on EXIT trap in aubshell |
Date: |
Thu, 13 Oct 2016 10:00:41 +0200 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 |
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' INT; echo $BASH_SUBSHELL;
kill -s INT $BASHPID)
Actual output: 1 1
Expected output: 1 1
Thanks,
- Martijn
- BASH_SUBSHELL reset to 0 on EXIT trap in aubshell,
Martijn Dekker <=