From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@sunsite.dk
Subject: Re: use 'P' parameter expansion flag with array?
Date: Tue, 30 Jun 2009 17:19:44 +0200 [thread overview]
Message-ID: <237967ef0906300819g4c0a6059rfac9d21b565cc4f0@mail.gmail.com> (raw)
In-Reply-To: <m363edn4in.fsf@klanderman.net>
2009/6/30 Greg Klanderman <gak@klanderman.net>:
>
>> It does seem logical, but the code is obscure and it's not clear whether
>> this was intended or not---it probably fell through the cracks.
>
> Thank you Peter, I'll just use a loop then..
>
>> paramsubst() is full of my "one day someone should spend a year tidying
>> this up" comments.
>
> Yeah I enjoyed reading a number of those last night after sending
> that question :-)
>
> So if I have an array and want to append a string to each of the
> elements, then join with colon, is there a better way than this:
>
> lwm% a=(x y z)
> lwm% echo ${(j.:.)${(@)a/%/foo}}
> xfoo:yfoo:zfoo
>
> I was trying to do something using '^' but it doesn't seem to work;
>
> lwm% echo ${(@)^a}foo
> xfoo yfoo zfoo
>
> does what I expect, but:
>
> lwm% echo ${(j.:.)${(@)^a}foo}
> zsh: bad substitution
>
> does not.
echo ${(j.:.):-${(@)^a}foo}
will work fine, the simplest case of the error is this, i think:
% echo ${${}foo}
zsh: bad substitution
% echo ${:-${}foo}
foo
--
Mikael Magnusson
next prev parent reply other threads:[~2009-06-30 15:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-30 3:20 Greg Klanderman
2009-06-30 8:43 ` Peter Stephenson
2009-06-30 15:08 ` Greg Klanderman
2009-06-30 15:19 ` Mikael Magnusson [this message]
2009-06-30 15:51 ` Greg Klanderman
2009-07-05 19:56 ` Bart Schaefer
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=237967ef0906300819g4c0a6059rfac9d21b565cc4f0@mail.gmail.com \
--to=mikachu@gmail.com \
--cc=zsh-workers@sunsite.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).