Earlier quoted context omitted.
I had this problem as well. The same trivial shell scripting problems came up over and over. My solution was to write a static analysis tool (ShellCheck) that would recognize them automatically and with enough confidence would even auto-answer. It's gotten way more use than I ever expected. Haven't made much progress on the plaintext question problem though. Some day!
Cool! It's also written in Haskell. I always wanted to take a closer look at that language and this project seems just about the right size!
What worked well was unit testing and Haskell. What didn't work as well was inventing adhoc solutions instead of standard compiler techniques like DFA/CFG, and not writing more and better DSLs (in the form of monadic APIs) since they're cheap and convenient.