Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
'command -pv zsh' => 'zsh: command not found: -pv'
- X-seq: zsh-workers 29565
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: 'command -pv zsh' => 'zsh: command not found: -pv'
- Date: Wed, 20 Jul 2011 18:23:10 +0300
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:subject:message-id :mime-version:content-type; s=smtpout; bh=ySw2p5QWUB2U8JxG3D+4vw elJDs=; b=ftZPwlE83R+vJz0W+/PBuiOHvwCVO3RxnFnB6KuLizMwvxdjQYhs5n b/PuOcJcooQg4ZJs5HZDW7T8e1khGaL2DYO3lUmvXeI4ujkcuNXnHVAHzTv0tnnn nlh8cITqP5i7FizrqCITb8USWFvQxM80oo0l1p3RFI3zdIfWqyNWc=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Actual behaviour:
t1% command -pv zsh
zsh: command not found: -pv
Expected behaviour:
Look for a 'zsh' executable in the default $PATH and print its path.
(i.e., print '/usr/local/bin/zsh'.)
Environment:
t1% zsh -f
t1% echo $ZSH_VERSION
4.3.10
Mikael Magnusson reported on IRC that he can reproduce that locally,
using a more recent zsh.
---
Looking into the cause, I guess that it's due to this bit of argument
parsing in ./Src/exec.c:2433:
[[[
if ((cflags & BINF_COMMAND) && nextnode(firstnode(args))) {
/* check for options to command builtin */
char *next = (char *) getdata(nextnode(firstnode(args)));
char *cmdopt;
if (next && *next == '-' && strlen(next) == 2 &&
(cmdopt = strchr("pvV", next[1])))
{
if (*cmdopt == 'p') {
]]]
I've looked into converting that parsing to a while() loop (as used by
other if() blocks in the vicinity), but haven't got a working patch yet
and didn't want to delay this email until I did.
diff --git Src/exec.c Src/exec.c
index f5b59a3..cc1682d 100644
--- Src/exec.c
+++ Src/exec.c
@@ -2433,22 +2433,31 @@ execcmd(Estate state, int input, int output, int how, int last1)
/* check for options to command builtin */
char *next = (char *) getdata(nextnode(firstnode(args)));
char *cmdopt;
- if (next && *next == '-' && strlen(next) == 2 &&
- (cmdopt = strchr("pvV", next[1])))
- {
- if (*cmdopt == 'p') {
- uremnode(args, firstnode(args));
- use_defpath = 1;
- if (nextnode(firstnode(args)))
- next = (char *) getdata(nextnode(firstnode(args)));
- } else {
- hn = &commandbn.node;
- is_builtin = 1;
+ while (next && *next == '-' && strlen(next) >= 2) {
+ uremnode(args, firstnode(args));
+ if (!strcmp(next, "--"))
break;
+ for (cmdopt = &next[1]; *cmdopt; ++cmdopt) {
+ switch (*cmdopt) {
+ case 'p':
+ use_defpath = 1;
+ break;
+ case 'v':
+ case 'V':
+ is_builtin = 1;
+ break;
+ default:
+ zerr("unknown command flag -%c", *cmdopt);
+ errflag = lastval = 1;
+ return;
+ }
}
+ next = (char *) getdata(nextnode(firstnode(args)));
+ }
+ if (is_builtin) {
+ hn = &commandbn.node;
+ break;
}
- if (!strcmp(next, "--"))
- uremnode(args, firstnode(args));
}
if ((cflags & BINF_EXEC) && nextnode(firstnode(args))) {
/*
Messages sorted by:
Reverse Date,
Date,
Thread,
Author