X-Git-Url: https://sipb.mit.edu/gitweb.cgi/wiki.git/blobdiff_plain/4f7205948f37fe6fec864c025e16a72b0afe2eab..907666ed95bdf187babac064565c876c66b9321e:/doc/safe-shell.mdwn?ds=sidebyside diff --git a/doc/safe-shell.mdwn b/doc/safe-shell.mdwn index f4bb32a..7c9bbb3 100644 --- a/doc/safe-shell.mdwn +++ b/doc/safe-shell.mdwn @@ -36,7 +36,7 @@ In dash, `set -o` doesn't exist, so use only `set -euf`. What do those do? -### `[set](http://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html) -e` +### [`set -e`](http://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html) If a command fails, `set -e` will make the whole script exit, instead of just resuming on the next line. If you have commands that can fail without it being @@ -44,11 +44,11 @@ an issue, you can append `|| true` or `|| :` to suppress this behavior — for example `set -e` followed by `false || :` will not cause your script to terminate. -### `[set](http://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html) -u` +### [`set -u`](http://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html) Treat unset variables as an error, and immediately exit. -### `[set](http://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html) -f` +### [`set -f`](http://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html) Disable filename expansion (globbing) upon seeing `*`, `?`, etc.. @@ -58,7 +58,7 @@ you may find -s failglob` useful, which causes globs that don't get expanded to cause errors, rather than getting passed to the command with the `*` intact. -### [set](http://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html) -o pipefail +### [`set -o pipefail`](http://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html) `set -o pipefail` causes a pipeline (for example, `curl -s http://sipb.mit.edu/ | grep foo`) to produce a failure return code if any command errors. Normally,