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*

2
  • 1
    It's more complex than this. Calling trap - [SIG_SPEC] doesn't revert to previous trap, it reverts to "the value it had upon entrance to the shell". This could be blank, or inherited from the parent shell. It wil not revert to one you previously set in the current shell. There is no trap stack other than that created each time you spawn a subshell. In other words if you set a trap for a given SIG_SPEC and then set it again the first one is replaced by the second. Commented Sep 1, 2021 at 20:43
  • But could you make function run in subshell (like, func() ( … )) then? Commented Jul 13, 2024 at 8:31