zsh-workers
 help / color / mirror / code / Atom feed
From: "Andrej Borsenkow" <borsenkow.msk@sni.de>
To: <mason@primenet.com.au>, <zsh-workers@sunsite.auc.dk>
Subject: RE: zsh-3.1.5-pws-14: parameter expansion not working properly
Date: Mon, 12 Apr 1999 10:51:11 +0400	[thread overview]
Message-ID: <003001be84b0$d9790490$21c9ca95@mowp.siemens.ru> (raw)
In-Reply-To: <slrn7gudfb.fb4.mason@coral.primenet.com.au>

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


  reply	other threads:[~1999-04-12  7:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-04-10 11:28 BUG: " Geoff Wing
1999-04-12  6:51 ` Andrej Borsenkow [this message]
1999-04-12  7:35   ` Geoff Wing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='003001be84b0$d9790490$21c9ca95@mowp.siemens.ru' \
    --to=borsenkow.msk@sni.de \
    --cc=mason@primenet.com.au \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).