3 ms·
Since we're using `-o` already, we might like the equivalent "longoptions" form: ``` set -o errexit -o nounset -o noclobber -o pipefail ``` But `pipefail` isn
by xelxebar 8y ago
Since we're using `-o` already, we might like the equivalent "longoptions" form:
```
set -o errexit -o nounset -o noclobber -o pipefail
```
But `pipefail` isn't part of POSIX and will fail in dash, tcsh, and friends, so it's arguably better to go ahead and use your shell-specific builtin whenever possible---`shopt` for bash, `setopt` for zsh, etc.
```
shopt -s -o errexit nounset noclobber pipefail
```
For that matter, if we're using shell-specific features, we might as well use the appropriate bang pattern:
```
#!/usr/bin/env bash
```
or similar. It's also really nice that Shellcheck differentiates between shells based on bang patterns and changes it's behavior accordingly.
Also, I can't help but mention the bash unit testing framework, BATS!