Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Is "command" working right, yet?



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.



Messages sorted by: Reverse Date, Date, Thread, Author