Subject: Re: [BUG] quoting within bracket patterns has no effect
From: Martijn Dekker <[email-masked]>
To: [email-masked]
Cc: Peter Stephenson <[email-masked]>
Date: Sat, 23 Jan 2016 00:17:44 +0000
List-Id: Zsh Workers List <zsh-workers.zsh.org>

> On Mon, 18 Jan 2016 05:23:07 +0100
> Martijn Dekker <[email-masked]> wrote:
>> > Quotes should disable the special meaning of characters in glob
>> > patterns[*].
>> >
>> > [*] "If any character (ordinary, shell special, or pattern special) is
>> > quoted, that pattern shall match the character itself."
>> > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13_01

In the current git version of zsh (zsh-5.2-97-g1aec003), this bug is now
fixed for literal patterns:

case b in
( ['a-c'] ) echo 'false match' ;;
( [a-c] )   echo 'correct match' ;;
esac

outputs "correct match" as expected.

However, for variables there is now a new problem, the opposite of the
old one: unlike in every other shell, a range is not recognised even if
the variable is *not* quoted. So quoting a variable still has no effect,
it's just that range parsing from variables was disabled altogether. The
following code:

myrange='a-z'
somevar='c'
case $somevar in
( *[$myrange]* )  echo "$somevar is part of $myrange" ;;
esac

outputs "c is part of a-z" on every shell except current zsh.

Quoting the variable ( *["$myrange"]* ) should make it output nothing.

Thanks,

- M.