[Top][All Lists]
[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: |
Gary V. Vaughan |
Subject: |
Re: [PATCH 6/7] syntax-check: fix violations and implement sc_prohibit_test_const_follows_var. |
Date: |
Tue, 22 Nov 2011 12:54:08 +0700 |
Hi Stefano,
On 22 Nov 2011, at 03:13, Stefano Lattarini wrote:
> Hi Gary. Few more random nits...
Thanks ;)
> On Monday 21 November 2011, Gary V 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'.
>>
> This seems "back-bending" to me, and slightly unclear to read. Also,
> it goes against the (unofficial) conventions of autoconf, which is
> to use either `test "x$b" = xa' or `test "x$b" = Xa'.
I was unable to find any shells that choke on:
test a != -b || echo bug
Where it's easy to upset test with:
test -b != a
> Also ...
>
>> # Bootstrap this package from checked-out sources.
>> # Written by Gary V. Vaughan, 2010
>> @@ -1760,7 +1760,7 @@ func_ifcontains ()
>> ;;
>> esac
>>
>> - test "$_G_status" -eq 0 || exit $_G_status
>> + test 0 -eq $_G_status || exit $_G_status
>> }
> ... changes like this seems overly paranoid, in case $_G_status is
> expected (as I surmise it is) to be a non-negative integer. And
> if this assumption stps to hold dur to a bug in your code, you are
> going to be bitten by much worse problem anyway:
Well, in addition to saving a few characters of typing, and being
consistent with other uses of test after this patch, it also prevents
the syntax-check from triggering.
I certainly wouldn't expect any difference in behaviour either way,
even on buggy shells/test implementations.
> # $shell is either Solaris 1 0or AT&T ksh, Solaris 10 XPG4 sh, or
> # zsh 4.3.12.
> $ $shell -c 'exit t; echo foo'; echo status = $?
> status = 0
Cheers,
--
Gary V. Vaughan (gary AT gnu DOT org)
- [PATCH 5/7] syntax-check: fix violations and implement sc_useless_braces_in_variable_derefs., (continued)
Re: [PATCH 6/7] syntax-check: fix violations and implement sc_prohibit_test_const_follows_var., Stefano Lattarini, 2011/11/21
- Re: [PATCH 6/7] syntax-check: fix violations and implement sc_prohibit_test_const_follows_var.,
Gary V. Vaughan <=
Re: [PATCH 1/7] syntax-check: fix violations and implement sc_useless_quotes_in_case., Eric Blake, 2011/11/21
Re: [PATCH 1/7] syntax-check: fix violations and implement sc_useless_quotes_in_case., Gary V. Vaughan, 2011/11/25