Last active
December 18, 2020 06:31
-
-
Save adrianriobo/6c8760b8fd408ea42c04e251a1c00067 to your computer and use it in GitHub Desktop.
Proper way to create bash scripts with set command included
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -exuo pipefail | |
[explanation](https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425) | |
# kill all the child processes for this script when it exits | |
trap 'jobs=($(jobs -p)); ((${#jobs})) && kill "${jobs[@]}" || true; exit 0' TERM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment