Subject: Re: [BUG] quoting within bracket patterns has no effect
From: Bart Schaefer <[email-masked]>
To: [email-masked]
Date: Fri, 22 Jan 2016 17:49:49 -0800
List-Id: Zsh Workers List <zsh-workers.zsh.org>

On Jan 23, 12:17am, Martijn Dekker wrote:
}
} 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.

This is related to long-standing behavior for zsh in native mode.

In as-close-as-zsh-has-to-POSIX mode:

schaefer[655] ARGV0=sh Src/zsh
$ myrange='a-z'
$ somevar='c'
$ case $somevar in
> ( *[$myrange]* )  echo "$somevar is part of $myrange" ;;
> esac
c is part of a-z
$ 

In native mode you need to use $~param to activate pattern characters
in the expanded value:

schaefer[656] Src/zsh -f
torch% myrange='a-z'
torch% somevar='c'
torch% case $somevar in
case> ( *[$~myrange]* )  echo "$somevar is part of $myrange" ;;
case> esac
c is part of a-z
torch% 

It's true that needing this inside a character class now differs from
previous versions of zsh for native mode.  I'm not sure it's possible
to have it both ways.