Mike Frysinger wrote: > On Monday 24 September 2007, Donnie Berkholz wrote: >> >> You could use C-style syntax here: >> >> (( use_errors++ )) >> >> I find it a bit more readable. > > i like to get anal and use ((++use_errors)) > > then again, it may also be more readable like so: > use_errors=false > if ... ; then > ... > use_errors=true > fi > if ... ; then > ... > use_errors=true > fi > ${use_errors} && die "..." > -mike
Integer arithmetic is generally quicker: ((use_errors++)) [or: use_errors=1 ] .. ((use_errors)) && die 'meh' -- although true and false are builtins in this case. For stuff like for ((i=0;i<n;i++)) arithmetical context[1] is significantly quicker than for i in {0..15} say, and more flexible (variable bound and step-size, if desired.) The boolean test on an integer eg ((use_errors)) is a metaphor I use a lot, eg: ((quiet)) || echo oops; ((verbose>1)) && echo blah It's handy as unset vars test to false, and also as the usual boolean values apply, ie 0 is false, anything else is true. (Outside this context 0 is true [success from cmd] and anything else is false [error code].) And ofc, you don't need to put $ in front of your standard variables in this context. [1] http://wooledge.org/mywiki/ArithmeticExpression -- [EMAIL PROTECTED] mailing list