- Use shellcheck (static analysis/linter) https://www.shellcheck.net/
- Use shunit2 (unit tests) https://github.com/kward/shunit2
- Use 'local' or 'readonly' to annotate your variables
- Trap ctrl+c to gracefully exit (details here https://www.tothenew.com/blog/foolproof-your-bash-script-som...)
- Stick to long-form options for readability (--delete over -d for example)
- #!/usr/bin/env > #!/bin/bash for portability
- Consider setting variable values in a file and importing it at the top of your script to improve refactoring
- You will eventually forget how your scripts work - seriously consider if Bash is your best option for anything that needs to last a while!
- Use shellcheck (static analysis/linter) https://www.shellcheck.net/
- Use shunit2 (unit tests) https://github.com/kward/shunit2
- Use 'local' or 'readonly' to annotate your variables
- Trap ctrl+c to gracefully exit (details here https://www.tothenew.com/blog/foolproof-your-bash-script-som...)
- Stick to long-form options for readability (--delete over -d for example)
- #!/usr/bin/env > #!/bin/bash for portability
- Consider setting variable values in a file and importing it at the top of your script to improve refactoring
- You will eventually forget how your scripts work - seriously consider if Bash is your best option for anything that needs to last a while!