SHARE
TWEET

SET BASH

philyuchkoff Oct 18th, 2019 (edited) 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top