libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 6/7] syntax-check: fix violations and implement sc_prohibit_t


From: Eric Blake
Subject: Re: [PATCH 6/7] syntax-check: fix violations and implement sc_prohibit_test_const_follows_var.
Date: Mon, 21 Nov 2011 13:07:51 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1

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   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]