On 11/21/2011 07:47 AM, Gary V. Vaughan wrote: > To safely use a non-literal first argument to `test', you must > always prepend a literal non-`-' character, but often the second > operand is a constant that doesn't begin with a `-' already, so > always use `test a = "$b"' instead of noisy `test "X$b" = Xa'.
Not true. test a = "$b" is just as likely to trigger improper evaluation in buggy test(1) implementations as: test "$b" = a If you cannot guarantee the contents of "$b", then you MUST prefix both sides of the comparison with x or X. Conversely, if you CAN guarantee the contents of "$b" (for example, if you did b=$?, then you KNOW that b is a numeric tring with no problematic characters), then you might as well use the more idiomatic comparison of variable to constant. -- Eric Blake ebl...@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature