On Saturday 26 April 2008, Denys Vlasenko wrote: > On Saturday 26 April 2008 05:26, Mike Frysinger wrote: > > > > [ -n "$var" ] is clear. [ "$var" ] is not. > > > > > > it's exactly analogous to "if (foo != 0)" vs. "if (foo)". > > > > > > it's all subjective. i'd probably have to look up "-n". :-) > > > > i doubt it's the same. most people who understand shell coding know what > > the -n test means. i would doubt that most people know what the default > > behavior is if no operator is specified at all. unlike C coders who know > > that "true" means "non-0". > > http://en.wikipedia.org/wiki/Color_of_the_bikeshed ?
as i explained, it isnt just subjective, thus this does not apply. my assertion is that every C coder knows that "if (foo)" and "if (foo != 0)" is the same thing. shell coding is a much looser art form and a lot less people know that [ "$foo" ] is the same thing as [ -n "$foo" ]. ive seen people make [ "$foo" ] explicit, but do it wrong because they didnt really understand what the implicit behavior was in the first place. and when quizzed directly, many havent the foggiest. if the only people working on the shell code in question were you, myself, and a few other people, then yes, [ "$foo" ] is fine because i'm assured we all know these fugly little details in our head. but we arent the only ones touching it. -mike
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ busybox mailing list [email protected] http://busybox.net/cgi-bin/mailman/listinfo/busybox
