Hacker News new | ask | show | jobs
by Grimeton 320 days ago
You can just do

  trap 'caller 1' ERR
should do the same thing. Also you should set "errtrace" (-E) and possibly "nounset" (-u) and "pipefail".
1 comments

or even use caller to print a full backtrace: https://news.ycombinator.com/item?id=44636927
That's neat, but if your bash script needs a backtrace it should not be a bash script. To each their own though.
My bash scripts don't "need" a backtrace, but it sure is nicer than not having one