From: Zoltan Hidvegi <hzoli@cs.elte.hu>
To: vlefevre@ens-lyon.fr (Vincent Lefevre)
Cc: zsh-users@math.gatech.edu
Subject: Re: zsh 3.0.1 bug? read -c
Date: Wed, 30 Oct 1996 17:09:48 +0100 (MET) [thread overview]
Message-ID: <199610301609.RAA03910@labor5.cs.elte.hu> (raw)
In-Reply-To: <199610292327.AAA22922@boukha.ens-lyon.fr> from Vincent Lefevre at "Oct 30, 96 00:27:48 am"
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;
}
prev parent reply other threads:[~1996-10-30 16:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-10-29 23:27 Vincent Lefevre
1996-10-30 16:09 ` Zoltan Hidvegi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199610301609.RAA03910@labor5.cs.elte.hu \
--to=hzoli@cs.elte.hu \
--cc=vlefevre@ens-lyon.fr \
--cc=zsh-users@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).