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

Re: typeset question



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