On 12/29/16 10:39 PM, Eduardo Bustamante wrote: > I'm adding the bug-bash list, since I think this is actually a bug in > the parse_comsub function, or maybe in execute_command_internal. I > haven't been able to figure it out yet. What I do know is that these > two should behave the same: > > dualbus@yaqui:~$ cat -n h > 1 #!/bin/bash > 2 shopt -s extdebug > 3 main() { > 4 trap 'echo $LINENO' ERR > 5 (exit 17) > 6 } > 7 main > dualbus@yaqui:~$ ./h > 3 > > --- vs --- > > dualbus@yaqui:~$ cat -n i > 1 #!/bin/bash > 2 shopt -s extdebug > 3 main() { > 4 trap 'echo $LINENO' ERR > 5 `exit 17` > 6 } > 7 main > dualbus@yaqui:~$ ./i > 5 > > There's no actual reason for these two to be different,
It's the difference between a simple command, which has a line number, and a subshell command, which does not. The subshell command's line number is derived from the execution context, which is relative to the start of the function. The OP wants the subshell's line number to be absolute, like the simple command's, and not relative to the start of the function, as it is now. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/