Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: command cd doesn't work on some builds of zsh
- X-seq: zsh-workers 52540
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: Ajeet D'Souza <98ajeet@xxxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: command cd doesn't work on some builds of zsh
- Date: Tue, 13 Feb 2024 12:02:22 +0000 (GMT)
- Archived-at: <https://zsh.org/workers/52540>
- Importance: Normal
- In-reply-to: <CAF6KdoXdvvhTUEcNf+XmjemdS1CDFzhs-gjze=R94_tcMzWbiQ@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAF6KdoXAt7KWtCSJXj+Dk6Sw3v7-b0rxmGBb5BwTqvUnN5EMpg@mail.gmail.com> <Zcs-51EmF9RJNF6L@harpo.local> <CAF6KdoXdvvhTUEcNf+XmjemdS1CDFzhs-gjze=R94_tcMzWbiQ@mail.gmail.com>
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