From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11388 invoked by alias); 25 Sep 2016 23:31:57 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 39438 Received: (qmail 13402 invoked from network); 25 Sep 2016 23:31:57 -0000 X-Qmail-Scanner-Diagnostics: from kahlil.inlv.org by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(37.59.109.123):SA:0(-3.1/5.0):. Processed in 0.49753 secs); 25 Sep 2016 23:31:57 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=RP_MATCHES_RCVD autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: martijn@inlv.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at inlv.org does not designate permitted sender hosts) Subject: Re: Is "command" working right, yet? To: zsh-workers@zsh.org References: <160202163744.ZM2066@torch.brasslantern.com> <56B761B8.6000507@inlv.org> From: Martijn Dekker Message-ID: Date: Mon, 26 Sep 2016 00:31:48 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <56B761B8.6000507@inlv.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit 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.