philyuchkoff Oct 18th, 2019 (edited) 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- Отсюда: https://github.com/philyuchkoff/the-art-of-command-line
- In Bash scripts, use set -x (or the variant set -v, which logs raw input, including unexpanded variables and comments) for debugging output. Use strict modes unless you have a good reason not to: Use set -e to abort on errors (nonzero exit code). Use set -u to detect unset variable usages. Consider set -o pipefail too, to abort on errors within pipes (though read up on it more if you do, as this topic is a bit subtle). For more involved scripts, also use trap on EXIT or ERR. A useful habit is to start a script like this, which will make it detect and abort on common errors and print a message:
- set -euo pipefail
- trap "echo 'error: Script failed: see failed command above'" ERR
RAW Paste Data