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

PATCH: 3.1.5-pws-5++: typeset -T fixlet



Ho scritto io:
> By the way, it seems to me
> 
> % typeset -T FOO foo
> % foo="scalar"
> % print $FOO
> 
> %
> 
> is probably a bug, so I'll try to remember to have a look at it.

Seems quite easy to fix along the same lines that PATH/path were
supposed to work, and I've documented the behaviour.  There is a also
a fix to an existing bug here:

% PATH=(array)
% print $PATH
<nasty eight bit characters>

This was supposed to be handled, but a slight misunderstanding of the
parameter type flags (a scalar has a zero value) caused it to be
missed.

--- Doc/Zsh/builtins.yo.tied2	Thu Jan 28 18:04:21 1999
+++ Doc/Zsh/builtins.yo	Sat Jan 30 14:07:46 1999
@@ -910,7 +910,10 @@
 the former.  Only the scalar may have an initial value.  Both the
 scalar and the array may otherwise be manipulated as normal.  If one
 is unset, the other will automatically be unset too.  There is no way
-of untying the variables without unsetting them; tt(+T) does not work.
+of untying the variables without unsetting them, or converting the
+type of one them with another tt(typeset) command; tt(+T) does not work,
+assigning an array to var(SCALAR) is an error, and assigning a scalar
+to var(array) sets it to be a single-element array.
 
 If no var(name) is present, the names and values of all parameters are
 printed.  In this case the attribute flags restrict the the display to
--- Src/params.c.tied2	Fri Jan 29 17:36:10 1999
+++ Src/params.c	Sat Jan 30 14:02:11 1999
@@ -1371,7 +1371,7 @@
 	freearray(val);
 	return;
     }
-    if (PM_TYPE(v->pm->flags) & ~(PM_ARRAY|PM_HASHED)) {
+    if (!(PM_TYPE(v->pm->flags) & (PM_ARRAY|PM_HASHED))) {
 	freearray(val);
 	zerr("attempt to assign array value to non-array", NULL, 0);
 	return;
@@ -1501,7 +1501,7 @@
 	if (!(v = getvalue(&s, 1)))
 	    createparam(t, PM_SCALAR);
 	else if (PM_TYPE(v->pm->flags) == PM_ARRAY &&
-		 !(v->pm->flags & PM_SPECIAL) && unset(KSHARRAYS)) {
+		 !(v->pm->flags & (PM_SPECIAL|PM_TIED)) && unset(KSHARRAYS)) {
 	    unsetparam(t);
 	    createparam(t, PM_SCALAR);
 	    v = NULL;
@@ -1545,7 +1545,7 @@
 	if (!(v = getvalue(&s, 1)))
 	    createparam(t, PM_ARRAY);
 	else if (!(PM_TYPE(v->pm->flags) & (PM_ARRAY|PM_HASHED)) &&
-		 !(v->pm->flags & PM_SPECIAL)) {
+		 !(v->pm->flags & (PM_SPECIAL|PM_TIED))) {
 	    int uniq = v->pm->flags & PM_UNIQUE;
 	    unsetparam(t);
 	    createparam(t, PM_ARRAY | uniq);

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



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