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

typeset -U broken in 3.1.2?

With respect to 'typeset -U', the manual says: "For arrays keep only the
first element of each duplications". 
This would be nice if you could define arrays with 'typedef', but you
can't, because in contrast to 'set', 'typeset' has no '-A' option (BTW,
why not??) and doesn't treat brace expressions specially.

After some experimenting I found that

1. outside a function, 'typeset -U x' works _only_ if 'x' has already
been defined as  an array;
2. inside a function, 'typeset -U x' doesn't work at all.

Look at this script:

	function f
	   typeset a	# 1
	   a=(x y x y)
	   print "f: a=$a"
	   typeset -U a	# 2
	   print "f: a=$a"

	unset a
	print "t: a=$a"

It prints: 

	f: a=x y x y
	f: a=
	t: a=x y x y

Instead of sorting the array and discarding the duplications, the second
typeset _destroys_ the value of 'a'. And the last output line reveals
that 'a' is not local to the function, as it should be.

Any comments (or, preferably, patches)?

Bernd Eggink
Regionales Rechenzentrum der Uni Hamburg

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