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

Re: Remind me why ${name+word} is the way it is?



On Fri, 11 Nov 2016 20:34:00 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> Noodling with something else and ...
> 
> torch% name='foo[bar]'
> torch% echo ${name}
> foo[bar]
> torch% echo ${name+foo[bar]}
> zsh: no matches found: foo[bar]
> torch% print -l ${name+foo bar}
> foo bar
> 
> So the "word" in ${name+word} and variants is not subject to splitting,
> but is subject to globbing, even though (w/o GLOB_SUBST SH_WORDSPLIT)
> ${name} is not subject to either of those.

It's obviously needed for the parameter operators with pattern
matching that things don't get quoted.  (Except when they already are
double-quoted and need unquoting.)

I don't know of a good reason why the operators that just substitute a
value are like that.  It may just be no special case was ever added.

pws



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