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

Re: command -p should enable builtins not in path

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
>[*] (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"?


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:


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

Vincent Lefèvre <vincent@xxxxxxxxxx> - 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)

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