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

Re: PATCH: small parameter fix



>  > 
>  >   ${${...}[...]}
>  > 
>  > previously didn't really work: if the inner ${...} produced an array
>  > with only one element, the outer ${...} treated it as a string and the 
>  > subscript gave the n'th character.
> 
> AHA!  This must be the reason that "${${(@)...}...}" is required in so
> many mystifying circumstances.  I, too, would like to hear whether the
> previous behavior was intentional ... this change does potentially
> break scripts, including I think 3.0.5 scripts, so we'd better tread
> carefully.

in particular it has this effect:

% print "${$(uname -n)[1]}"
ibmth

where you might guess $(...) in quotes produced a scalar for subscripting
--- indeed it did, but the subscripting decided to treat it as an array
element.  In fact, since the nested substitution recognises the quotes
whereas the subscripting doesn't, you get,

% print "${${path}[1]}"
/home/user2/pws/bin /home/user2/pws/links /home/user2/pws/mh/bin
/home/user2/pws/scripts /usr/local/bin /usr/sue/bin /usr/bin /usr/bin/X11
/usr/ucb /usr/local/bin/X11 /cern/pro/bin /usr/local/cap /etc .

(wrapped a bit --- well, you don't get that, but I do) which is distinctly
on the strange side.  I would suggest that in quotes the old behaviour
character-subscripting behaviour is the right one.

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



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