In this final chapter, we'll look at some techniques for programming in Bash defensively, safely, and productively, in a way that makes working with shell scripts a joy rather than a chore, especially by avoiding some nasty pitfalls in the language.
We'll revisit the following material from earlier chapters in more depth:
- Quoting correctly
- Handling filenames starting with dashes
- Separating output and diagnostics
We'll also cover:
- Keeping scripts brief and simple
- Keeping scripts flexible
- Respecting and applying the user's configuration
- Allowing scripts to run without user input
- Limiting the scope of shell state changes
- Avoiding path anti-patterns
- Avoiding Bash for untrusted user input
- Documenting scripts
- Using temporary files cleanly
- Cleaning up after a script
- A tool to check shell scripts for problems