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
> 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@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