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
  • Alternatively, if ! mkdir "$LOCKDIR"; then handle failure to lock and exit; fi trap and do processing after if-statement. Commented Feb 22, 2018 at 13:19
  • 1
    It's worth pointing out that the trap definition must remain at the global scope of the script. Moving that mkdir block inside a function will result in cleanup: command not found. (I learned this the hard way) Commented Dec 2, 2020 at 20:13