]> sipb.mit.edu Git - wiki.git/blobdiff - doc/safe-shell.mdwn
fix markup
[wiki.git] / doc / safe-shell.mdwn
index f4bb32aa4290667790f0f22760b83332ef33892c..7b8f60114a3a8c1d31d64a9138d8451fbb67fa60 100644 (file)
@@ -36,7 +36,7 @@ In dash, `set -o` doesn't exist, so use only `set -euf`.
 
 What do those do?
 
 
 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
 
 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,21 +44,20 @@ 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.
 
 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.
 
 
 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..
 
 If your script depends on globbing, you obviously shouldn't set this. Instead,
 you may find
 
 Disable filename expansion (globbing) upon seeing `*`, `?`, etc..
 
 If your script depends on globbing, you obviously shouldn't set this. Instead,
 you may find
-`[shopt](http://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html)
--s failglob` useful, which causes globs that don't get expanded to cause
+[`shopt -s failglob`](http://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html) useful, which causes globs that don't get expanded to cause
 errors, rather than getting passed to the command with the `*` intact.
 
 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,
 
 `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,
@@ -102,6 +101,10 @@ manual](http://www.gnu.org/software/bash/manual/html_node/Special-Parameters.htm
 for details on the distinction between `$*`, `$@`, and `"$@"` — the first
 and second are rarely what you want in a safe shell script.
 
 for details on the distinction between `$*`, `$@`, and `"$@"` — the first
 and second are rarely what you want in a safe shell script.
 
+## Temporary files
+
+TODO: mumble `mktemp`?
+
 ## Conclusion
 
 When possible, instead of writing a "safe" shell script, *use a higher-level
 ## Conclusion
 
 When possible, instead of writing a "safe" shell script, *use a higher-level