programming/ShellLoopIndexes written at 00:25:34; Add Comment
A shell script thing that I have learned the hard way
Here is a note to myself about shell scripting, especially things that I
write on the fly on the command line: under no circumstance should I use
I say this because, based on experimental evidence so far, I am
completely sure to use
(This is where someone recommends '
The Bourne shell isn't the only language where it's not an error to use an undefined variable, of course. While it's tempting to say that this behavior is a bad idea, that's really treating the symptom and not the disease; my real mistake is using the wrong index variable, not using an undefined variable. Catching the symptom would only save me until the day when I write:
(I suspect that the usual general proposal to deal with this is to make loop index variables go out of scope at the end of loops.)
Sidebar: where this came from
Today's version of this lesson was writing:
The goal was to clean up some ZFS pool state, but instead it did nothing at all (the
* * *
Atom feeds are available; see the bottom of most pages.