2019-03-31 17:05:09 +08:00
.. _cmd-command:
2018-12-17 09:39:33 +08:00
command - run a program
2019-01-03 12:10:47 +08:00
=======================
2018-12-17 09:39:33 +08:00
2018-12-18 09:58:24 +08:00
Synopsis
--------
2018-12-17 05:08:41 +08:00
command [OPTIONS] COMMANDNAME [ARGS...]
2018-12-18 09:58:24 +08:00
2018-12-17 05:08:41 +08:00
2018-12-19 10:44:30 +08:00
Description
2019-01-03 12:10:47 +08:00
-----------
2018-12-17 05:08:41 +08:00
2018-12-20 04:02:45 +08:00
`` command `` forces the shell to execute the program `` COMMANDNAME `` and ignore any functions or builtins with the same name.
2018-12-17 05:08:41 +08:00
The following options are available:
2019-03-15 04:07:10 +08:00
- `` -a `` or `` --all `` returns all the external COMMANDNAMEs that are found in `` $PATH `` in the order they are found.
2018-12-17 05:08:41 +08:00
2019-02-25 07:01:16 +08:00
- `` -q `` or `` --quiet `` , silences the output and prints nothing, setting only the exit code. Implies `` --search `` .
2018-12-17 05:08:41 +08:00
2018-12-20 04:02:45 +08: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-17 05:08:41 +08:00
2018-12-20 04:02:45 +08: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-17 05:08:41 +08:00
2018-12-20 04:02:45 +08:00
For basic compatibility with POSIX `` command `` , the `` -v `` flag is recognized as an alias for `` -s `` .
2018-12-17 05:08:41 +08:00
2018-12-19 10:44:30 +08:00
Examples
2019-01-03 12:10:47 +08:00
--------
2018-12-17 05:08:41 +08:00
2018-12-20 04:02:45 +08:00
`` command ls `` causes fish to execute the `` ls `` program, even if an `` ls `` function exists.
2018-12-17 05:08:41 +08:00
2018-12-20 04:02:45 +08:00
`` command -s ls `` returns the path to the `` ls `` program.
2018-12-17 05:08:41 +08:00
2019-02-25 07:01:16 +08:00
`` command -q git; and command git log `` runs `` git log `` only if `` git `` exists.