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

Re: vared 'functions[xx]'



On Thu, 13 Dec 2007 17:27:07 +0000
Stephane Chazelas <stephane_chazelas@xxxxxxxx> wrote:
> ~$ vared functions\[a\]\
>         echo foobar

[and then only after hitting return to accept the edit...]

> zsh: not an identifier: functions[a]
> 
> Still, vared showed me the content of $functions[a]. I would
> have expected it to return with an error before (well instead
> of) allowing me to edit the content.

The story here is that vared is using the flag to the parameter that
indicates braces are present.  They aren't, actually, it's just a trick
to get extra parameter effects to work.  So the parameter code doesn't
care if there's extra stuff after the bits it's handled; the caller
needs to check.  When setting the value, the parameter code needs to be
able to parse the entire expression and gives an error if it can't.

Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.100
diff -u -r1.100 zle_main.c
--- Src/Zle/zle_main.c	19 Oct 2007 01:33:09 -0000	1.100
+++ Src/Zle/zle_main.c	13 Dec 2007 21:38:55 -0000
@@ -1441,6 +1441,10 @@
 	zwarnnam(name, "no such variable: %s", args[0]);
 	return 1;
     } else if (v) {
+	if (*s) {
+	    zwarnnam(name, "not an identifier: `%s'", args[0]);
+	    return 1;
+	}
 	if (v->isarr) {
 	    /* Array: check for separators and quote them. */
 	    char **arr = getarrvalue(v), **aptr, **tmparr, **tptr;


-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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