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

Re: command cd doesn't work on some builds of zsh



On 13/02/2024 11:48 GMT Ajeet D'Souza <98ajeet@xxxxxxxxx> wrote:
> Also, since the manpage mentions that command is supposed to invoke
> shell builtins, why does this command fail
> without POSIX_BUILTINS being set? Is cd not considered a builtin
> otherwise?

No, builtins are *only* invoked by "command" when POSIX_BUILTIN is set.
(As I said, native zsh uses "builtin", not "command", for restricting to
builtins.)  The manual page is clear about this:


command [ -pvV ] simple command

The simple command argument is taken as an external command instead of
a function or builtin and is executed. 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.


In your case the zsh "builtin" command is more useful, because as you
note you quite definitely don't want to execute the external command
"cd".

pws




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