zsh-workers
 help / color / mirror / code / Atom feed
* vared 'functions[xx]'
@ 2007-12-13 17:27 Stephane Chazelas
  2007-12-13 21:23 ` Peter Stephenson
  2007-12-13 21:41 ` Peter Stephenson
  0 siblings, 2 replies; 3+ messages in thread
From: Stephane Chazelas @ 2007-12-13 17:27 UTC (permalink / raw)
  To: Zsh hackers list

Hiya,

I had an odd behavior here.

~$ a() echo foo
~$ vared functions\[a\]\
        echo foobar
zsh: not an identifier: functions[a]
~$ dpkg -l | grep zsh
ii  zsh-beta                             4.3.4-dev-4+20071212-1      A shell with lots of features (dev tree)

Above, the trailing "\ " was added by the completion system.

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.

Same goes for:

a=foo
vared "a "

Not a big issue, though.

Cheers,
Stephane


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: vared 'functions[xx]'
  2007-12-13 17:27 vared 'functions[xx]' Stephane Chazelas
@ 2007-12-13 21:23 ` Peter Stephenson
  2007-12-13 21:41 ` Peter Stephenson
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2007-12-13 21:23 UTC (permalink / raw)
  To: Zsh hackers list

On Thu, 13 Dec 2007 17:27:07 +0000
Stephane Chazelas <stephane_chazelas@yahoo.fr> wrote:
> I had an odd behavior here.
> 
> ~$ a() echo foo
> ~$ vared functions\[a\]\
> 
> Above, the trailing "\ " was added by the completion system.

This stops that happening.  I think it's fine in that we certainly need
one level less of quoting to the space than to the square brackets.
However, if there are multiple levels of quoting involved it gets
hairier.  That's probably not a problem in practice.

I'll see if there's something funny in vared separately.

Index: Completion/Zsh/Context/_subscript
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Context/_subscript,v
retrieving revision 1.11
diff -u -r1.11 _subscript
--- Completion/Zsh/Context/_subscript	16 Apr 2002 07:48:46 -0000	1.11
+++ Completion/Zsh/Context/_subscript	13 Dec 2007 21:22:23 -0000
@@ -3,8 +3,8 @@
 local expl ind osuf=']' flags sep
 
 if [[ "$1" = -q ]]; then
-  osuf='] '
   compquote osuf
+  osuf+=' '
   shift
 fi
 

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: vared 'functions[xx]'
  2007-12-13 17:27 vared 'functions[xx]' Stephane Chazelas
  2007-12-13 21:23 ` Peter Stephenson
@ 2007-12-13 21:41 ` Peter Stephenson
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2007-12-13 21:41 UTC (permalink / raw)
  To: Zsh hackers list

On Thu, 13 Dec 2007 17:27:07 +0000
Stephane Chazelas <stephane_chazelas@yahoo.fr> 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@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-12-13 21:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-13 17:27 vared 'functions[xx]' Stephane Chazelas
2007-12-13 21:23 ` Peter Stephenson
2007-12-13 21:41 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).