about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2002-09-19 17:57:56 +0000
committerBart Schaefer <barts@users.sourceforge.net>2002-09-19 17:57:56 +0000
commita1d727e5dcfc209a1bdc798f293da21ecd68062d (patch)
tree710497c1d253a17e072f7df5105c590d92aaa756 /Src
parent41b50445eab2eb71c4446f85e368a273b52c39a3 (diff)
downloadzsh-a1d727e5dcfc209a1bdc798f293da21ecd68062d.tar.gz
zsh-a1d727e5dcfc209a1bdc798f293da21ecd68062d.tar.xz
zsh-a1d727e5dcfc209a1bdc798f293da21ecd68062d.zip
17692: Prevent typeset of a positional parameter before it can do damage,
and improve the error message about it.
Diffstat (limited to 'Src')
-rw-r--r--Src/builtin.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 36b780e8c..95f3b6f57 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -1909,7 +1909,7 @@ typeset_single(char *cname, char *pname, Param pm, int func,
 		    "%s: array elements must be scalar", pname, 0);
 	    return NULL;
 	}
-    } else if (isident(pname)) {
+    } else if (isident(pname) && !idigit(*pname)) {
 	/*
 	 * Create a new node for a parameter with the flags in `on' minus the
 	 * readonly flag
@@ -1918,7 +1918,10 @@ typeset_single(char *cname, char *pname, Param pm, int func,
 	DPUTS(!pm, "BUG: parameter not created");
 	pm->ct = auxlen;
     } else {
-	zerr("not an identifier: %s", pname, 0);
+	if (isident(pname))
+	    zerrnam(cname, "not valid in this context: %s", pname, 0);
+	else
+	    zerrnam(cname, "not an identifier: %s", pname, 0);
 	return NULL;
     }