Please stop writing shell scripts
That’s when you realize your mistake: bash, and shell scripting languages in general, are mostly broken by default. Unless you are very careful from day one, any shell script above a certain complexity level is almost guaranteed to be buggy… and retrofitting the correctness features is quite difficult.
Source: Please stop writing shell scripts, an article by Itamar Turner-Trauring.