If you write any Bash code that lasts more than a day, you should definitely read “Defensive BASH Programming” and follow the advice, if you haven’t already. It covers the following:
- Immutable global variables
- Everything is local
- main()
- Everything is a function
- Debugging functions
- Code clarity
- Each line does just one thing
- Printing usage
- Command line arguments
- Unit Testing
All that with code examples and explanation of importance.