choice of control operators in scripts

Paul Fox pgf at brightstareng.com
Mon May 12 14:06:25 PDT 2008


 > > If you fell paranoid today (highly recommended),
 > > add x"" to guard against less than ideal implementations of []
 > > which can be confused by e.g. foo=-n :
 > >
 > > [ x"$foo" = x"bar" ]
 > 
 > I have no experience of shells that are _so_ buggy.  Do you mean this:
 > 
 > [ x-n = xbar ]
 > 
 > might confuse any non-buggy shell?

no.  he means that this:
  [ "-n" = "bar" ]

might confuse a shell that interprets it as:
  [ -n = bar ]

i've never seen such a shell.  i think adding the 'x' "just in
case" is very ugly.  just putting the args to test in double
quotes has always been enough for me.

paul
=---------------------
 paul fox, pgf at brightstareng.com


More information about the busybox mailing list