Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: typeset question
- X-seq: zsh-workers 3569
- From: Bernd Eggink <eggink@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers mailing list <zsh-workers@xxxxxxxxxxxxxxx>
- Subject: Re: typeset question
- Date: Thu, 09 Oct 1997 15:23:36 +0200
- Cc: Peter Stephenson <pws@xxxxxx>
- Organization: RRZ Uni Hamburg
- References: <199710091153.NAA04186@xxxxxxxxxx>
- Sender: rz2a022@xxxxxxxxxxxxxxxxxx
Peter Stephenson wrote:
>
> 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)'.
My confusion was caused by a curious property of 'typeset'. If the
variable
is already defined as a normal variable, and if it is an array, typeset
does _nothing_. In all other cases it works as expected. Try this:
x=a
typeset x=b
print $x # prints: b
OK... Now try
unset x
x=(a b c)
typeset x=(x y z)
print $x # prints: a b c
The contents of the brace gets evaluated, but no assignment takes place.
Bug or
feature? It's not documented nor does it make sense to me.
--
Bernd Eggink
Regionales Rechenzentrum der Uni Hamburg
eggink@xxxxxxxxxxxxxxxxxx
http://www.rrz.uni-hamburg.de/eggink/BEggink.html
Messages sorted by:
Reverse Date,
Date,
Thread,
Author