Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
brace expansion inconsistency
- X-seq: zsh-workers 16385
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: brace expansion inconsistency
- Date: Wed, 02 Jan 2002 16:08:46 +0000
- Cc: Matt Armstrong <matt+dated+1010258681.d5e28d@xxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <87ellbxkek.fsf@xxxxxxxxxxxxxxxxxxx>
- Sender: kiddleo@xxxxxxxxxxxxxxxxx
Matt Armstrong wrote:
>
> Is there a simple way to turn an array (a b c) into (a "" b "" c "")?
> Then I could assign _p4_cmds in one statement and dump the loop.
>
I would have thought that _p4_cmds=( {$a,} ) would do the job but
it doesn't. On closer inspection, it seems that {,$a} does expand
in the way I would expect with alternate array elements and empty
strings.
In bash {x,} expands to just 'x'. ksh 93 expands it to two
words - 'x' and an empty word. zsh is different for
{x,} and {,x}. I'd argue that ksh93 is right.
Any thoughts?
And, Matt, for now, you could use this:
a=( {,$a} )
typeset -A _p4_cmds
_p4_cmds=( "${(@)a[2,-1]}" '' )
Oliver
This email has been scanned for all viruses by the MessageLabs SkyScan service. For more information on a pro-active anti-virus service working around the clock, around the globe visit http://www.messagelabs.com/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author