Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
RE: zsh-3.1.5-pws-14: parameter expansion not working properly
- X-seq: zsh-workers 6006
- From: "Andrej Borsenkow" <borsenkow.msk@xxxxxx>
- To: <mason@xxxxxxxxxxxxxxx>, <zsh-workers@xxxxxxxxxxxxxx>
- Subject: RE: zsh-3.1.5-pws-14: parameter expansion not working properly
- Date: Mon, 12 Apr 1999 10:51:11 +0400
- Importance: Normal
- In-reply-to: <slrn7gudfb.fb4.mason@xxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Yes, as I understand, it was changed in pws-14. It includes full description
of subst rules in Parameters expansion section of manual.
Basically, in quotes, the value of inner substitution is always forced to be
scalar for outer substitution unless some flags or modifiers (notably, =,
(@), (s)) prevent it.
> % zsh-3.1.5-pws-14
> % a=("${(f@)$(echo foo; echo bar)}"); print -l $a
> foo
> bar
(@) is not needed. (f) is already enough - first, the value of $(...) is
forced to scalar and then it is splitted using (f) flag. The result is
*always* array - in this case it is top-level one so nothing more happens.
> % a=("${${(f@)$(echo foo; echo bar)}:#f*}"); print -l $a
>
Yep. The first ${(f)$(...)} yields array value. The outer ${...} first
converts array to scalar (because the whole is quoted) and then applies # to
scalar. To preserve "arrayness" you need (@) for outer subst:
bor@itsrm2:~%> a=("${(@)${(f@)$(echo foo; echo bar)}:#f*}"); print -l $a
bar
So, it is not a bug, it is by desing. There was a long thread here, where I
tried to understand what ZSH substitution rules actually are. I admit (now
:-) that current state is more or less consistent. The problem is, it is
near to impossible to explain difference between pws-14 and earlier versions
because it is the first time these rules are explicitly stated.
/andrej
Messages sorted by:
Reverse Date,
Date,
Thread,
Author