2019-03-31 09:05:09 +00:00
.. _cmd-command:
2018-12-17 01:39:33 +00:00
command - run a program
2019-01-03 04:10:47 +00:00
=======================
2018-12-17 01:39:33 +00:00
2018-12-18 01:58:24 +00:00
Synopsis
--------
2018-12-16 21:08:41 +00:00
2019-09-17 09:59:04 +00:00
::
2018-12-18 01:58:24 +00:00
2019-09-17 09:59:04 +00:00
command [OPTIONS] COMMANDNAME [ARGS...]
2018-12-16 21:08:41 +00:00
2018-12-19 02:44:30 +00:00
Description
2019-01-03 04:10:47 +00:00
-----------
2018-12-16 21:08:41 +00:00
2018-12-19 20:02:45 +00:00
`` command `` forces the shell to execute the program `` COMMANDNAME `` and ignore any functions or builtins with the same name.
2018-12-16 21:08:41 +00:00
The following options are available:
2019-03-14 20:07:10 +00:00
- `` -a `` or `` --all `` returns all the external COMMANDNAMEs that are found in `` $PATH `` in the order they are found.
2018-12-16 21:08:41 +00:00
2019-09-17 08:31:39 +00:00
- `` -q `` or `` --quiet `` , silences the output and prints nothing, setting only the exit status. Implies `` --search `` .
2018-12-16 21:08:41 +00:00
2018-12-19 20:02:45 +00:00
- `` -s `` or `` --search `` returns the name of the external command that would be executed, or nothing if no file with the specified name could be found in the `` $PATH `` .
2018-12-16 21:08:41 +00:00
2018-12-19 20:02:45 +00:00
With the `` -s `` option, `` command `` treats every argument as a separate command to look up and sets the exit status to 0 if any of the specified commands were found, or 1 if no commands could be found. Additionally passing a `` -q `` or `` --quiet `` option prevents any paths from being printed, like `` type -q `` , for testing only the exit status.
2018-12-16 21:08:41 +00:00
2018-12-19 20:02:45 +00:00
For basic compatibility with POSIX `` command `` , the `` -v `` flag is recognized as an alias for `` -s `` .
2018-12-16 21:08:41 +00:00
2018-12-19 02:44:30 +00:00
Examples
2019-01-03 04:10:47 +00:00
--------
2018-12-16 21:08:41 +00:00
2018-12-19 20:02:45 +00:00
`` command ls `` causes fish to execute the `` ls `` program, even if an `` ls `` function exists.
2018-12-16 21:08:41 +00:00
2018-12-19 20:02:45 +00:00
`` command -s ls `` returns the path to the `` ls `` program.
2018-12-16 21:08:41 +00:00
2019-02-24 23:01:16 +00:00
`` command -q git; and command git log `` runs `` git log `` only if `` git `` exists.