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

Re: typeset question

Bernd Eggink wrote:
> I'm confused... These two statements work fine and give the same
> results:
> 	typeset x=(a b c)
> 	x=($(cat file))

Actually, the first is not an array assignment; there is nothing
syntactically special about the parentheses in a typeset statement.
(In fact, it does grouping in all statements, to make globs using
parentheses work sensibly, which is why the spaces don't separate words,
but even so typeset just gets the string `x=(a b c)').  You should find
x contains the string '(a b c)'.

> But this one does _not_ work:
> 	typeset x=($(cat file))
> Output:
> 	zsh: not an identifier: c)

As the outer (...) is not special, the $(cat file) splits the thing
into three arguments: x=(a, b and c).  typeset complains about the last

The fix is to do `typeset x' first, then the array assignment to x in
a separate statement.

Peter Stephenson <pws@xxxxxx>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77413
Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, Platanenallee 6, 15738 Zeuthen, Germany.

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