libtool-patches
[Top][All Lists]
Advanced

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

Re: deplibs_check_method=test_compile


From: Gary V. Vaughan
Subject: Re: deplibs_check_method=test_compile
Date: Tue, 07 Feb 2006 13:06:54 +0000
User-agent: Thunderbird 1.5 (X11/20051201)

Ralf Wildenhues wrote:
> Hi Gary,

Hallo Ralf,

> * Gary V. Vaughan wrote on Sat, Feb 04, 2006 at 02:38:53AM CET:
>> Ralf Wildenhues wrote:
> *snip*
>>> -         if test "$name" != "" && test "$name" -ne "0"; then
>>> +         if test "$name" != "" && test "$name" != 0; then
>>                                                        ^^
>> s/-ne/!=/ agreed... but I prefer to leave "0" alone.
> *snip*
>>> -         if test "$name" != "" && test "$name" != "0"; then
>>> +         if test "$name" != "" && test "$name" != 0; then
>>                                                     ^^
>> Huh?  != is the string comparison operator, so I like that it was
>> explicit with "0".  Does this really cause a spurious error?
> 
> No, of course the two changes you point out do not cause or fix any
> errors.  So it is a matter of personal preference.

Sure.

>> Just nit-picking really.  If you would rather drop the quotes, I'm
>> not overly fussed.  Yes, please apply.
> 
> Thanks.  I have applied the patch without the two changes, to HEAD and
> branch-1-5, because the bugs were there, too.  Both shown below.

Cool.  Thanks.

> But I'd like to mention a couple of sentences of rationale for above.
> Many times I have seen users code like this
>    if test $parameter = "value" ...
> rather than
>    if test "$parameter" = value ...
> 
> , and your comment:
>> != is the string comparison operator, so I like that it was
>> explicit with "0".

Agreed... it is just a stylistic convention that I like to use, where
string comparisons in test have quotes, and the number in a numeric
comparison is not quoted.  In either case, one must quote the variable
expanded side of the comparison in case of multi-word, or zero-length
expansion.

> is also indicative of a common and wide-spread misconception:
> Quoting here is not done at all because of `test', but because parameter
> expansion may result in more than one `word'.  `test' will never ever
> get to see the quotes.  And the string `0' simply won't be changed by
> any of shell expansions, so it will never result in more than one word.
> The fact that `test' is often a builtin command rather than an external
> program is completely irrelevant to this; and IMVHO the fact that
> numeric comparisons are usually not done in the same command line with
> parameters that expand to one word is a coincidence; quoting is also
> used to prevent parameters from expanding to zero words; that '' is not
> a valid number is another coincidence.  All IMVHO, of course.
> 
> I have come to prefer more minimal quoting in examples, in order to make
> above difference a bit more explicit: it took me a long time to grasp
> this peculiarity of shell syntax.

You have grasped it?!  I still have to resort to typing at the prompt
to figure out what I need in some cases.

One other thing that comes to mind (and the main reason for this reply),
is that there is a good argument that the following is never entirely
safe:

    test "$w00t" -ne 0

because it doesn't allow for dangerous expansions of "$w00t" to, say,
`-x'.  So we really ought to using:

    test x"$w00t" != "x0"

and so perhaps we should add a TODO item to perform that fix throughout
libtool's shell code, and fixup HACKING to note this idio{m,sycracy}?

Cheers,
        Gary.
-- 
Gary V. Vaughan      ())_.  address@hidden,gnu.org}
Research Scientist   ( '/   http://tkd.kicks-ass.net
GNU Hacker           / )=   http://www.gnu.org/software/libtool
Technical Author   `(_~)_   http://sources.redhat.com/autobook

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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