From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: nested substitution documentation
Date: Wed, 17 Mar 1999 12:43:20 +0100 (MET) [thread overview]
Message-ID: <199903171143.MAA27007@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Peter Stephenson's message of Wed, 17 Mar 1999 12:09:39 +0100
Peter Stephenson wrote:
> One thing is a little inconsistent: if $foo is an array, "${foo[1]}"
> produces the first word of foo (this is certainly correct), but
> "${${(@)foo}[1]}" produces the first character.
I don't think this is inconsistent, because it is quoted but there is
no `(@)' in the outer `${...}' that would say to use separate words
for the inner `${...}'.
> I wanted to say `the
> result of a nested substitution is treated exactly as if came directly from
> a scalar or array parameter', but that's not true in this case. Maybe all
> array values should be subscripted word-wise by the next enclosing
> substitution, regardless of double quotes. But then how do you index on
> characters? And is this (which was my guess of how to do it) right:
>
> % foo=(bar baz)
> % print ${foo[@][1]}
> bar
> % print "${foo[@][1]}"
> bar
>
> ([*] does the same in both cases)? "${foo[1][1]}" does work the way I
> would expect.
As for your examples, I think this is right. But with `[*]' it should
produce the first character when the whole thing is quoted.
And while we are at it: I also wanted to point out that `(@)' isn't
the same as an `[@]' with nested expansions because the `[@]' is found
after the inner thing has been expanded and so the value is already
split in elements (or not). Another slightly ugly thing.
Bye
Sven
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~1999-03-17 11:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-03-17 11:43 Sven Wischnowsky [this message]
-- strict thread matches above, loose matches on Subject: below --
1999-03-17 11:09 Peter Stephenson
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=199903171143.MAA27007@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--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).