zsh-workers
 help / color / mirror / code / Atom feed
From: Vincent Lefevre <vincent@vinc17.net>
To: zsh-workers@zsh.org
Subject: Re: command -p should enable builtins not in path
Date: Fri, 2 Oct 2020 15:17:53 +0200	[thread overview]
Message-ID: <20201002131753.GA154103@zira.vinc17.org> (raw)
In-Reply-To: <99d03601-babc-14c7-21b5-41a7a8c90eab@inlv.org>

On 2020-08-24 20:59:52 +0100, Martijn Dekker wrote:
> Op 24-08-20 om 19:30 schreef Vincent Lefevre:
> > However, "command cd" is not guaranteed to work in a POSIX shell,
> > e.g. if $PATH has changed.
> 
> That's actually not true, 'cd' is intrinsically a built-in utility (it
> couldn't possibly function otherwise, as it must affect the current
> environment)

Well, AFAIK, some OS's provide a way for processes to affect the
environment of their parent. So an implementation could theoretically
choose to provide cd as an external utility.

> and it is also explicitly exempt from a $PATH search by XCU
> 2.9.1.4(d)[*] (not that most shells follow that absurd $PATH search
> rule for builtins anyway, but that's a different rant). Point being,
> POSIXly, 'command cd' is safe.

OK, I agree.

So, shouldn't this be changed to match the POSIX behavior for the
utility list from "Command Search and Execution"?

  https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01_01

I'm wondering whether any zsh user relies on an external program
for such utilities. Or, if there is any issue with such a change,
add another option, similar to POSIX_BUILTINS, but restricted to
this list.

FYI, I've just found that the "command -p" was added in Intel's scripts
because of a bug report from a user who defined a function named cd:

  https://posts663.rssing.com/chan-20519098/all_p8.html

("command" would have been sufficient as you said, but there would
be the same problem in zsh).

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


  reply	other threads:[~2020-10-02 13:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-20 11:28 Vincent Lefevre
2020-08-21 13:03 ` Peter Stephenson
2020-08-21 15:49   ` Martijn Dekker
2020-08-21 16:08     ` Peter Stephenson
2020-08-21 16:35       ` Martijn Dekker
2020-08-24 18:30     ` Vincent Lefevre
2020-08-24 19:59       ` Martijn Dekker
2020-10-02 13:17         ` Vincent Lefevre [this message]
2020-08-21 15:47 ` Martijn Dekker

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=20201002131753.GA154103@zira.vinc17.org \
    --to=vincent@vinc17.net \
    --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).