Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: var to Array conversion ?
- X-seq: zsh-users 11178
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: var to Array conversion ?
- Date: Sat, 03 Feb 2007 11:46:05 +0100
- In-reply-to: <20070203103353.GF18652@xxxxxxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Operating-system: Linux 2.6.19.2-suspend2+ipw2200 i686
- References: <20070203.095013.74742848.Meino.Cramer@xxxxxx> <20070203103353.GF18652@xxxxxxxxxxxxxxx>
Frank Terbeck <ft@xxxxxxxxxxxxxxxxxx>:
> Meino Christian Cramer <Meino.Cramer@xxxxxx>:
> > In a shell script a variable foo is set to 2.0:3.5:0.2
> > a=2.0:3.5:0.2
> > is there a any short one liner to convert the contents of a into
> > the contents which would result from an assignment like
> > a=(2.0 3.5 0.2)
>
> See 'man zshbuiltins' (the 'typeset' builtin, '-T' option).
>
> Example:
>
> [snip]
> # 3rd arg. to typeset -T is optional (default ':').
> typeset -T string array ':'
> string="one:two:three:four"
> array+=five
> print -l $array
> [snap]
Note, that if you really want conversion you can do it like this:
[snip]
string="one:two:three:four"
array=(${(s,:,)string})
print -l $array
[snap]
Regards, Frank
--
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
-- RFC 1925
Messages sorted by:
Reverse Date,
Date,
Thread,
Author