albertyw/albertyw.com

View on GitHub
app/notes/20190512-0522.md

Summary

Maintainability
Test Coverage
Bash Strict Mode

bash-strict-mode

1557638556

Bash is well-known to be a hard language to write in, with many somewhat
nonintuitive syntax requirements and edge cases.  However, unlike some
languages like Perl or Python, bash is available on basically every Unix
machine and is the lingua franca for systems scripting making it very hard to
avoid.  Therefore, adding this snippet to the top of every script will avoid
issues and make errors easier to debug.

```bash
set -exuo pipefail
IFS=$'\n\t'
```

Bonus: use `shellcheck` to lint bash code and suggest fixes.