
| From: William Park <opengeometry@yahoo.ca> | "set -u" won't help in case of foo= bar= rm -rf $foo/$bar Your mail client formats text in a funny way. If I look at the HTML, I see you meant: foo= fbar= rm -rf $foo/$bar No, of course it won't protect you if you actually aim your gun at your foot and pull the trigger. It just prevents some accidental discharges. Can you give a likely situation where you'd write code like that? If foo is to be a directory, the most likely default would be ".", not "". If fbar is to be a filename, "" makes no sense as a default. If fbar is to be a list of filenames, "" makes sense as a default, but then the rm command does not. My experience with retrofitting "set -eu" into other peoples' scripts is that it finds a lot of errors but many don't matter. That's because the other people have mostly debugged the script. On the other hand, the level of testing scripts is typically poor so any new way of testing finds bugs. If I write a script with "set -eu" I find my errors more quickly and thus reduce debugging time. The errors found are really easy to make and are sometimes hard to discover otherwise.