
| From: Chris F.A. Johnson <chris@cfajohnson.com> | It only causes the shell to exit if a simple command fails. Right. That does create some surprises. But these were all simple commands. And most of my errors are in simple commands. | Best practice is not to use it at all. | | <http://mywiki.wooledge.org/BashFAQ/105> Thanks. Useful. I respectfully disagree with the conclusion. | > "set -u" tells the shell to treat a reference to an undefined | > parameter as an error. It will make no difference in this script. | > Until the script evolves more complexity. | | There's no point to using set -u after a script has been debugged. The sad fact is that I don't know when I've gotten rid of the last bug in a script. It's really handy to have this on: I then know that most typos in parameter names will be caught so when I have a bug, I don't have to check for that kind of error myself and can concentrate on looking for other pathologies. Silently replacing a reference to a non-existent parameter with nothing is just dumb human engineering. I cannot find the Hoare quote that I'm looking for, but this seems to be a mangled version of it: Once said that removing type checking from your running programs and using them only for testing is like wearing a life jacket on your practice emergency drills and taking them off as soon as your ship was really sinking. <http://blog.mattcallanan.net/2010/09/tony-hoare-billion-dollar-mistake.html> Another relevant quote: a programming language designer should be responsible for the mistakes that are made by the programmers using the language (Hoare is a real great of our field.)