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

Re: var to Array conversion ?



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]

That is not exactly converting. It is more a way to connect a string
to an array, just as with the $PATH and $path or $FPATH and $fpath
parameters.

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