Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 2
    Interesting solution! Clearly more elegant than kill $$. Commented Sep 19, 2012 at 9:23
  • 4
    One thing to watch out for, this trap won't handle interpolated commands, e.g. echo "$(exit 77)"; the script will carry on as if we'd written echo "" Commented Mar 30, 2016 at 14:58
  • Interresting! Is there any luck on (quite older) bash that doesn't have -E ? maybe we have to resort to defining a trap on a USER signal and using a kill to that signal? I'll do some reasearch too... Commented Apr 6, 2016 at 18:44
  • How to know, when not being in a sub-shell trap, in order to return 1 instead of 77? Commented Nov 9, 2016 at 14:38