Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [BUG] quoting within bracket patterns has no effect



Bart Schaefer schreef op 23-01-16 om 01:49:
> This is related to long-standing behavior for zsh in native mode.
> 
> In as-close-as-zsh-has-to-POSIX mode:

(Which, by the way, is very close now.)

> 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.

In normal variable expansion, setting the option SH_WORD_SPLIT causes
unquoted $var to be equivalent to ${~var} in variable expansion.
Wouldn't it make sense to have SH_WORD_SPLIT activate pattern characters
in unquoted variables in range expressions as well? This would make zsh
under 'emulate sh' exactly compatible with bash, (d)ash, {pd,m}ksh and yash.

- Martijn



Messages sorted by: Reverse Date, Date, Thread, Author