zsh-workers
 help / color / mirror / code / Atom feed
From: Martijn Dekker <martijn@inlv.org>
To: zsh-workers@zsh.org
Subject: Re: Is "command" working right, yet?
Date: Mon, 26 Sep 2016 00:31:48 +0100	[thread overview]
Message-ID: <f8ffd815-f32d-c551-2fad-c939970927d3@inlv.org> (raw)
In-Reply-To: <56B761B8.6000507@inlv.org>

Op 07-02-16 om 15:24 schreef Martijn Dekker:
> Bart Schaefer schreef op 03-02-16 om 00:37:
> [...]
>> > burner% setopt posixbuiltins
>> > burner% command -p -V true
>> > zsh: command not found: -V
>> > burner% command -V -p true  
>> > command: bad option: -p
>> > 
>> > I think this is pretty clearly a bug.
> Agreed, these options should combine without a problem.

Resuming this old thread, it would be nice to get this fixed before zsh
5.3 is released. It's the only clear POSIX issue left on zsh that I know
of, and I've found a few in the past...

The culprit seems to be the simplistic option parsing code starting at
line 2664 in Src/exec.c (current git, e35dcae):

|            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') {
|                         uremnode(args, firstnode(args));
|                         use_defpath = 1;
|                         if (nextnode(firstnode(args)))
|                             next = (char *)
getdata(nextnode(firstnode(args)));
|                     } else {
|                         hn = &commandbn.node;
|                         is_builtin = 1;
|                         break;
|                     }
|                 }
|                 if (!strcmp(next, "--"))
|                      uremnode(args, firstnode(args));
|             }

Sure enough, it looks if there's one option and if there is, it happily
ignores the rest. Combined options like -pV also aren't supported.

I don't understand nearly enough about the zsh codebase to know why this
routine does its own option parsing rather than calling some common
option parsing function, so I can't offer suggestions for improvement
here that aren't likely to be completely stupid.

Thanks,

- M.


  reply	other threads:[~2016-09-25 23:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-03  0:37 Bart Schaefer
2016-02-07 15:24 ` Martijn Dekker
2016-09-25 23:31   ` Martijn Dekker [this message]
2016-09-26  3:13     ` Bart Schaefer
2016-09-26 10:56       ` Martijn Dekker
2016-09-26 17:02         ` Bart Schaefer
2016-09-27 10:08       ` Peter Stephenson
2016-09-27 12:15         ` Martijn Dekker
2016-09-28 10:30           ` Peter Stephenson
2016-09-28 18:37             ` Martijn Dekker
2016-09-29  8:55               ` Peter Stephenson
2016-10-11 13:40                 ` Martijn Dekker
2016-10-11 13:56                   ` Peter Stephenson
2016-10-11 16:20                     ` Martijn Dekker
2016-10-20 12:44                       ` Peter Stephenson
2016-10-20 13:06                         ` Peter Stephenson

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=f8ffd815-f32d-c551-2fad-c939970927d3@inlv.org \
    --to=martijn@inlv.org \
    --cc=zsh-workers@zsh.org \
    /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).