Re: Where is my Brave executable
On Mon, Dec 23, 2024 at 20:37:38 -0500, Jeffrey Walton wrote:
> On Mon, Dec 23, 2024 at 8:32 PM George at Clug <Clug@goproject.info> wrote:
> > Is this the main point to command? "will execute the external command ls instead of calling the function recursively"
Like many shell builtins, "command" does multiple things, depending on
how you use it. Suppressing function lookups is certainly *one* of the
things it does. Printing the first path of an external command is
another things that it does.
I already showed an example of a wrapper function that uses "command ls"
to run the external command instead of the function.
> Greg provided the link to the documentation:
>
> The "command" command's base functionality is specified by POSIX:
> <https://pubs.opengroup.org/onlinepubs/9799919799/utilities/command.html>
>
> And following the link:
>
> DESCRIPTION
>
> The command utility shall cause the shell to treat the arguments as a
> simple command, suppressing the shell function lookup that is described
> in 2.9.1.4 Command Search and Execution, item 1c.
And also:
When the -v or -V option is used, the command utility shall provide
information concerning how a command name is interpreted by the shell.
That feature is used when you want to determine whether something is
already installed.
hobbit:~$ if command -v firefox-esr >/dev/null; then echo firefox installed; fi
firefox installed
hobbit:~$ if command -v emacs >/dev/null; then echo emacs installed; fi
hobbit:~$
Obviously that's more useful in a script. If you're a human and you just
want that information for your own curiosity, "type" is a lot easier to
use:
hobbit:~$ type firefox-esr
firefox-esr is /usr/bin/firefox-esr
hobbit:~$ type emacs
bash: type: emacs: not found
Reply to: