Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: use 'P' parameter expansion flag with array?



2009/6/30 Greg Klanderman <gak@xxxxxxxxxxxxxx>:
>
>> 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



Messages sorted by: Reverse Date, Date, Thread, Author