Strict Error Settings

I recently revisited an old project and tried to get it up and running. First thing I noticed is that I'm providing the user terrible error messages because even I couldn't tell what was going on. Second thing I noticed was that I didn't follow best practices for writing bash scripts. I was being too lenient with errors and steamrolling over real issues instead of stopping at the first sign of trouble. Lesson for anyone that reads this is to always have the following in any bash script

#!/bin/bash -eu
set -o pipefail
# Rest of the script

Trust me, it will save you a lot of headache down the line.

Did you find this post useful? Show some love!
Classic DEV Post from Jun 3

Which programming language/environment is more โ€œpowerfulโ€ than people realize?

What software tool can do more than people realize or give it credit for? ...

david karapetyan
Dispassionate problem solver. I enjoy building minimal and efficient systems. I like to think I don't drink the kool-aid

The fastest growing software community.
Free forever.