Advertisement
philyuchkoff

SET BASH

Oct 18th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.75 KB | None | 0 0
  1. Отсюда: https://github.com/philyuchkoff/the-art-of-command-line
  2.  
  3. 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:
  4.  
  5.       set -euo pipefail
  6.       trap "echo 'error: Script failed: see failed command above'" ERR
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement