zsh-users
 help / color / mirror / code / Atom feed
* zsh 3.0.1 bug? read -c
@ 1996-10-29 23:27 Vincent Lefevre
  1996-10-30 16:09 ` Zoltan Hidvegi
  0 siblings, 1 reply; 2+ messages in thread
From: Vincent Lefevre @ 1996-10-29 23:27 UTC (permalink / raw)
  To: zsh-users

The first argument after "read -c" seems to be skipped, e.g.

$ repl () {
        read -c a0 a1 a2 a3
        echo
        echo "a0:" $a0
        echo "a1:" $a1
        echo "a2:" $a2
        echo "a3:" $a3
        reply=()
}
$ compctl -K repl testrepl
$ testrepl x y z [TAB]   (note: AUTO_MENU and LIST_AMBIGUOUS are set)
a0:
a1: testrepl
a2: x
a3: y

a0:
a1: testrepl
a2: x
a3: y

instead of

a0: testrepl
a1: x
a2: y
a3: z
...

-- 
Vincent Lefevre, vlefevre@ens-lyon.fr | Acorn RiscPC600, 20+1MB RAM, Eagle M2
http://www.ens-lyon.fr/~vlefevre      | Apple CD-300, SyQuest 270MB
PhD in Computer Science, 1st year     | Atari Falcon030, 4MB RAM
------------------------------------------------------------------------------


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

* Re: zsh 3.0.1 bug? read -c
  1996-10-29 23:27 zsh 3.0.1 bug? read -c Vincent Lefevre
@ 1996-10-30 16:09 ` Zoltan Hidvegi
  0 siblings, 0 replies; 2+ messages in thread
From: Zoltan Hidvegi @ 1996-10-30 16:09 UTC (permalink / raw)
  To: Vincent Lefevre; +Cc: zsh-users

Vincent Lefevre wrote:
> The first argument after "read -c" seems to be skipped, e.g.
> 
> $ repl () {
>         read -c a0 a1 a2 a3
>         echo
>         echo "a0:" $a0
>         echo "a1:" $a1
>         echo "a2:" $a2
>         echo "a3:" $a3
>         reply=()
> }
> $ compctl -K repl testrepl
> $ testrepl x y z [TAB]   (note: AUTO_MENU and LIST_AMBIGUOUS are set)
> a0:
> a1: testrepl
> a2: x
> a3: y

The patch below should fix it.  It changes the behaviour to behave more
like the the way described in the documentation.  E.g. read -c will read
all words to REPLY and read -c a b c reads the first word to a, the second
to b and the rest to c.

Zoltan


*** Src/builtin.c	1996/10/16 22:47:53	2.95
--- Src/builtin.c	1996/10/30 15:59:07
***************
*** 4980,4985 ****
--- 4980,4987 ----
  
      /* option -c is used in compctl functions */
      if (ops['c']) {
+ 	int i;
+ 
  	/* only allowed to be called by ZLE */
  	if (!inzlefunc) {
  	    zwarnnam(name, "option valid only in functions called from zle",
***************
*** 5006,5012 ****
  	    /* the -A option means that one array is specified, instead of
  	    many parameters */
  	    char **p, **b = (char **)zcalloc((clwnum + 1) * sizeof(char *));
- 	    int i;
  
  	    for (i = 0, p = b; i < clwnum; p++, i++)
  		*p = ztrdup(clwords[i]);
--- 5008,5013 ----
***************
*** 5015,5022 ****
  	    return 0;
  	}
  	if (ops['e'] || ops['E']) {
- 	    int i;
- 
  	    for (i = 0; i < clwnum; i++) {
  		zputs(clwords[i], stdout);
  		putchar('\n');
--- 5016,5021 ----
***************
*** 5025,5037 ****
  	    if (ops['e'])
  		return 0;
  	}
- 	if (*args) {
- 	    int i = 0;
  
! 	    for (; i < clwnum && *args; args++, i++)
! 		setsparam(*args, ztrdup(clwords[i]));
  	} else
! 	    setsparam("REPLY", ztrdup(clwords[clwpos]));
  
  	return 0;
      }
--- 5024,5046 ----
  	    if (ops['e'])
  		return 0;
  	}
  
! 	for (i = 0; i < clwnum && *args; reply = *args++, i++)
! 	    setsparam(reply, ztrdup(clwords[i]));
! 
! 	if (i < clwnum) {
! 	    int j, len;
! 
! 	    for (j = i, len = 0; j < clwnum; len += strlen(clwords[j++]));
! 	    bptr = buf = zalloc(len + j - i);
! 	    while (i < clwnum) {
! 		strucpy(&bptr, clwords[i++]);
! 		*bptr++ = ' ';
! 	    }
! 	    bptr[-1] = '\0';
  	} else
! 	    buf = ztrdup("");
! 	setsparam(reply, buf);
  
  	return 0;
      }


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

end of thread, other threads:[~1996-10-30 16:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-10-29 23:27 zsh 3.0.1 bug? read -c Vincent Lefevre
1996-10-30 16:09 ` Zoltan Hidvegi

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).