Skip to content

Instantly share code, notes, and snippets.

@adrianriobo
Last active December 18, 2020 06:31
Show Gist options
  • Save adrianriobo/6c8760b8fd408ea42c04e251a1c00067 to your computer and use it in GitHub Desktop.
Save adrianriobo/6c8760b8fd408ea42c04e251a1c00067 to your computer and use it in GitHub Desktop.
Proper way to create bash scripts with set command included
#!/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