I've updated the stackoverflow <http://stackoverflow.com/questions/41346907/bash-trap-how-to-get-line-number-of-a-subprocess-with-non-zero-status> question with more info.

I also tested:

     1  #!/bin/bash
     2  shopt -s extdebug
     3  main() {
     4  trap 'echo $LINENO' ERR
     5  $(exit 17)
     6  }
     7  main

The above also has the desired output of 5.

So, either form of command substitution gives the desired result, but using a subshell as in:

    (exit 17)

does not give the desired LINENO result.


Reply via email to