zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Is "command" working right, yet?
Date: Tue, 2 Feb 2016 16:37:44 -0800	[thread overview]
Message-ID: <160202163744.ZM2066@torch.brasslantern.com> (raw)

command [ -pvV ]
     The command word is taken to be the name of an external command,
     rather than a shell function or builtin.   If the POSIX_BUILTINS
     option is set, builtins will also be executed but certain special
     properties of them are suppressed. The -p flag causes a default
     path to be searched instead of that in $path. With the -v flag,
     command is similar to whence and with -V, it is equivalent to
     whence -v.

Prelimnaries:

I've created my own "true" at the head of $path to be able to distinguish
the builtin from the external command.  It just echoes EXTERNAL, like so:

burner% disable true
burner% true
EXTERNAL

First let's talk about option parsing.

burner% command -p -V true
zsh: command not found: -V
burner% command -V -p true
command: bad option: -p
burner% command -pv true
zsh: command not found: -pv

Those options can be combined in both bash and ksh.  Setting posixbuiltins
makes no difference to zsh:

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.

The next question has to do with builtins and path search.  There was a
long thread about this on the austin-group (POSIX standards) list several
weeks ago and I'm still not sure what the final outcome implies.  The
issue is the circumstances in which builtins are allowed to mask commands
in $PATH. Starting over with a fresh "zsh -f" so the builtin is enabled
and NO_POSIX_BUILTINS, "command" runs the external but "command -p" runs
the builtin:

burner% command true
EXTERNAL
burner% command -p true
burner% 

The latter seems a little odd to me, but I suppose that means that when
the doc says "a default path" it means one with builtins implicitly at the
front?  However, it relates to the last question:

Using the versions available on my Ubuntu desktop, and default $PATH, all
of bash, ksh, and zsh with POSIX_BUILTINS, execute the builtin for both
"command" and "command -p".  Anybody know if that's correct?  If it is,
how does one force the use of the external command in [the forthcoming]
POSIX?  (If it involves magic syntax in $PATH, I can't assert that zsh
is going to adopt it, but I'd still like to know the answer.)


             reply	other threads:[~2016-02-03  0:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-03  0:37 Bart Schaefer [this message]
2016-02-07 15:24 ` Martijn Dekker
2016-09-25 23:31   ` Martijn Dekker
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=160202163744.ZM2066@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --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).