Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ${=variable} doesn't always produce an array -- why?
- X-seq: zsh-workers 4070
- From: Zefram <zefram@xxxxxxxxx>
- To: schaefer@xxxxxxxxxxxxxxxx (Bart Schaefer)
- Subject: Re: ${=variable} doesn't always produce an array -- why?
- Date: Tue, 9 Jun 1998 21:11:34 +0100 (BST)
- Cc: zsh-workers@xxxxxxxxxxxxxxx
- In-reply-to: <980609124159.ZM6845@xxxxxxxxxxxxxxxxxxxxxxx> from "Bart Schaefer" at Jun 9, 98 12:41:58 pm
Bart Schaefer wrote:
>zsh% one="one"
>zsh% two="one two"
>zsh %echo ${${=one}[1]} ${${=two}[1]}
>o one
>
>This seems unintuitive to me. I was expecting to get the entire word "one"
>in both cases.
Ceteris paribus, I'd agree with your analysis of the above situation.
But to have ${one[1]} expand to "one" when SH_WORD_SPLIT is enabled
might be considered worse.
OTOH, I've been thinking that it might be better to adopt the ksh view
of scalar variables, that they are actually arrays of a single element.
That would make ${one[1]} in the above unambiguously refer to "one",
and make $= behave as you expected. It would also break a lot of
existing scripts in ways that could only partially be fixed by another
compatibility option.
-zefram
Messages sorted by:
Reverse Date,
Date,
Thread,
Author