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, Nov 11, 2016 at 08:34:00PM -0800, Bart Schaefer wrote:
> Noodling with something else and ...
> 
> torch% name='foo[bar]'
> torch% echo ${name}
> foo[bar]
> torch% echo ${name+foo[bar]}
When I was trying this I got this strange result of 'url-quote-magic':

% name=a;echo ${name:+foo[bar]}
zsh: no match
%
url-quote-magic:10: no match
%
url-quote-magic:10: no match
%
url-quote-magic:10: no match
%
url-quote-magic:10: no match
%    =
url-quote-magic:10: no match
%    ==
url-quote-magic:10: no match
%    ===
url-quote-magic:10: no match
%    ====
url-quote-magic:10: no match
%    =====

space and = cause the warning "url-quote-magic:10: no match". This only
can be triggered by running "name=a;echo ${name:+foo[bar]}" first.

> 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.
> 
> I know it's always been that way and I'm sure I knew why at some point.



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