Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: set -A
- X-seq: zsh-users 5891
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: set -A
- Date: Fri, 07 Feb 2003 17:36:53 +0000
- In-reply-to: ""Bart Schaefer""'s message of "Fri, 07 Feb 2003 16:48:56 GMT." <1030207164856.ZM25338@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
"Bart Schaefer" wrote:
> } But the `@' subscript is not documented to do anything useful for
> } strings
>
> That's not strictly true. The docs say, in consecutive paragraphs:
>
> ----------
> A subscript of the form `[*]' or `[@]' evaluates to all elements of an
> array; there is no difference between the two except when they appear
> within double quotes. [...]
>
> Subscripting may also be performed on non-array values, in which case
> the subscripts specify a substring to be extracted.
> ----------
>
> It does NOT say that subscripting non-array values is limited to using
> integer ranges; it just says "subscripting may also be performed."
The simple-minded reading would therefore be that the [@] has the same
behaviour for strings as for arrays --- i.e. whether the parameter
happens to be unset or not, and whether or not KSH_ARRAYS is in effect.
Does that break anything if KSH_ARRAYS isn't set? (Presumably it
doesn't break anything unless it relies on `undefined behaviour', hur
hur. But I don't think we can be that sanguine about the zsh
documentation, c.f. hitherto the undocumented set -A behaviour.)
> It's actually worse than that, though, because ksh treats ALL parameters
> as arrays -- in ksh, foo=xyz is the same as foo=(xyz) in zsh, and the
> fiction of string variables is maintained by making $foo a reference to
> ${foo[0]}. So when KSH_ARRAYS is set, ${foo[1]} (or any number greater
> than zero) ought to produce an empty result when used on a scalar.
Yes, that seems inevitable.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author