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

Re: segfault



On Jun 3, 11:38pm, Bart Schaefer wrote:
}
} All you need is ${(AA)1=} which tries to interpret the
} positional parameter $1 as a hash table.

Any obvious problems with the following?  Other than that t = "1" so it
ends up looking like a line number in the error message -- but I'm not
sure what to do with that without changing the error message format for
other parameters.


diff --git a/Src/params.c b/Src/params.c
index d92dd22..6fbee88 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -3242,12 +3242,17 @@ sethparam(char *s, char **val)
     if (!(v = fetchvalue(&vbuf, &s, 1, SCANPM_ASSIGNING))) {
 	createparam(t, PM_HASHED);
 	checkcreate = 1;
-    } else if (!(PM_TYPE(v->pm->node.flags) & PM_HASHED) &&
-	     !(v->pm->node.flags & PM_SPECIAL)) {
-	unsetparam(t);
-	/* no WARNCREATEGLOBAL check here as parameter already existed */
-	createparam(t, PM_HASHED);
-	v = NULL;
+    } else if (!(PM_TYPE(v->pm->node.flags) & PM_HASHED)) {
+	if (!(v->pm->node.flags & PM_SPECIAL)) {
+	    unsetparam(t);
+	    /* no WARNCREATEGLOBAL check here as parameter already existed */
+	    createparam(t, PM_HASHED);
+	    v = NULL;
+	} else {
+	    zerr("%s: can't change type of a special parameter", t);
+	    unqueue_signals();
+	    return NULL;
+	}
     }
     if (!v)
 	if (!(v = fetchvalue(&vbuf, &t, 1, SCANPM_ASSIGNING))) {



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