[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 8/7] syntax-check: fix violations and implement sc_useless_qu
From: |
Gary V. Vaughan |
Subject: |
Re: [PATCH 8/7] syntax-check: fix violations and implement sc_useless_quotes_in_case_branch. |
Date: |
Tue, 22 Nov 2011 15:21:00 +0700 |
Hi Eric,
On 22 Nov 2011, at 12:09, Gary V. Vaughan wrote:
> On 21 Nov 2011, at 23:15, Eric Blake wrote:
>> On 11/21/2011 07:47 AM, Gary V. Vaughan wrote:
>>> Contrary to popular belief, Bourne shell does not resplit case
>>> expressions after expansion, so if there are no shell unquoted
>>> shell metacharacters or whitespace, the quotes are useless.
>>> @@ -568,7 +568,7 @@ func_resolve_sysroot ()
>>> # store the result into func_replace_sysroot_result.
>>> func_replace_sysroot ()
>>> {
>>> - case "$lt_sysroot:$1" in
>>> + case $lt_sysroot:$1 in
>>> ?*:"$lt_sysroot"*)
>>
>> Likewise in the pattern expression; you could further change this to:
>>
>> case $lt_sysroot:$1 in
>> ?*:$lt_sysroot*)
>
> Good call, although narrowing the search down to eliminate false positives
> is a lot trickier in this case!
>
> I'm adding the following changeset to this series. Thanks!
Actually, no, I take it back. I won't apply that patch since it causes tests
to fail for at least dash, bash and ksh.
My reading of the opengroup specification agrees with us both that no
resplitting
should be done in the branch expressions of a case, but there is definitely
something odd going on that I don't really understand:
$ cat case.test
for match in '\$\$' '\$'; do
case $match in *$match*) echo good ;; *) echo bad ;; esac
case $match in *"$match"*) echo good ;; *) echo bad ;; esac
done
solaris10 /bin/sh$ sh case.test
good
good
good
good
solaris10 xpg4$ /usr/xpg4/bin/sh case.test
good
good
good
good
hpux10 /bin/sh$ sh case.test
good
good
good
good
aix6 /bin/sh$ sh case.test
good
good
good
good
zsh-4.3.10$ zsh case.test
good
good
good
good
zsh-4.3.11$ /usr/local/Cellar/zsh-4.3.11/bin/zsh case.test
good
good
good
good
zsh-4.3.12$ /usr/local/bin/zsh case.test
good
good
good
good
dash-0.5.7$ dash case.test
bad
good
good
good
bash-3.2.48$ bash case.test
bad
good
good
good
bash-4.1.5$ /usr/local/Cellar/bash-4.1.5/bin/bash case.test
bad
good
good
good
bash-4.2.10$ /usr/local/bin/bash case.test
bad
good
good
good
ksh-93s+$ ksh case.test
bad
good
good
good
Confusing! It seems any backslash escaped character will do, same
results with '\S\S' and '\S' as with the dollars above. Yet, with
the backslashes removed, all the above print 4 'good's.
If it weren't for the fact that ksh, bash and dash all independently
behave the same way, I'd have called it a bug... any idea?
Cheers,
--
Gary V. Vaughan (gary AT gnu DOT org)
- [PATCH 6/7] syntax-check: fix violations and implement sc_prohibit_test_const_follows_var., (continued)
Re: [PATCH 6/7] syntax-check: fix violations and implement sc_prohibit_test_const_follows_var., Stefano Lattarini, 2011/11/21
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