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

Moderately unhelpful error message



schaefer<565> history[12]="Bwahahahaha#"
zsh: read-only variable: 12

The following isn't an ideal patch.  For one thing, even in the case
where a member of an associative array is read-only, assignsparam()
returns v->pm which may not be NULL (but it seems as though perhaps a
NULL return ought to be what happens).  For another, this duplicates
the read-only test in a fifth location.

Index: Src/params.c
--- ../zsh-forge/current/Src/params.c	2010-10-10 17:11:35.000000000 -0700
+++ Src/params.c	2010-11-01 08:49:43.000000000 -0700
@@ -2591,8 +2591,15 @@
 	*ss = '\0';
 	if (!(v = getvalue(&vbuf, &s, 1)))
 	    createparam(t, PM_ARRAY);
-	else
+	else {
+	    if (v->pm->node.flags & PM_READONLY) {
+		zerr("read-only variable: %s", v->pm->node.nam);
+		*ss = '[';
+		zsfree(val);
+		return NULL;
+	    }
 	    flags &= ~ASSPM_WARN_CREATE;
+	}
 	*ss = '[';
 	v = NULL;
     } else {



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