On 4/1/18, 5:54 AM, "bug-bash on behalf of Martijn Dekker" <bug-bash-bounces+nchambers=lightspeedsystems....@gnu.org on behalf of mart...@inlv.org> wrote:
$ bash -c 'trap "echo WHOA" ERR; command false' WHOA WHOA Expected output: just one WHOA (as on *ksh, zsh) Thanks, - M. While you should still use the bashbug tool, I’m not sure if this is actually a bug. If you consider the following: NickChambers-iMac:~ Nick$ type command command is a shell builtin This means that when you execute `command false`, false is executed in a child subshell and command is executed in the current shell, and both return 1. Bash is able to see the exit status of false (since command is just a glorified C function in this case), so it activates the ERR trap. Then command exits, and bash once again activates the ERR trap (since command has the same exit status as the command it executed). If you execute `command false` in a subshell, bash will only see the exit status of command: NickChambers-iMac:~ Nick$ trap 'echo WHOA' ERR NickChambers-iMac:~ Nick$ ( command false ) WHOA NickChambers-iMac:~ Nick$