1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
= Command built-in
:encoding: UTF-8
:lang: en
//:title: Yash manual - Command built-in
The dfn:[command built-in] executes or identifies a command.
[[syntax]]
== Syntax
- +command [-befp] {{command}} [{{argument}}...]+
- +command -v|-V [-abefkp] {{command}}...+
[[description]]
== Description
Without the +-v+ (+--identify+) or +-V+ (+--verbose-identify+) option, the
built-in executes {{command}} with {{argument}}s in the same manner as the
last step of link:exec.html#simple[execution of simple commands].
The command is treated as a built-in or external command or a function
according to the options specified to the command built-in.
The shell does not exit on argument syntax error etc. even if the command is a
link:builtin.html#types[special built-in]
With the +-v+ (+--identify+) option, {{command}} is identified.
If the command is found in link:params.html#sv-path[+$PATH+], its full
pathname is printed.
If it is a link:syntax.html#tokens[keyword], link:exec.html#function[function], or link:builtin.html[built-in] that is not found in +$PATH+,
the command name is simply printed.
If it is an link:syntax.html#aliases[alias], it is printed in the form like
`alias ll='ls -l'`.
If the command is not found, nothing is printed and the exit status is
non-zero.
The +-V+ (+--verbose-identify+) option is similar to the +-v+ (+--identify+)
option, but the output format is more human-friendly.
[[options]]
== Options
+-a+::
+--alias+::
Search for the command as an link:syntax.html#aliases[alias].
Must be used with the +-v+ (+--identify+) or +-V+ (+--verbose-identify+)
option.
+-b+::
+--builtin-command+::
Search for the command as a link:builtin.html[built-in].
+-e+::
+--external-command+::
Search for the command as an external command.
+-f+::
+--function+::
Search for the command as a link:exec.html#function[function].
+-k+::
+--keyword+::
Search for the command as a link:syntax.html#tokens[keyword].
Must be used with the +-v+ (+--identify+) or +-V+ (+--verbose-identify+)
option.
+-p+::
+--standard-path+::
Search the system's default +PATH+ instead of the current
link:params.html#sv-path[+$PATH+].
+-v+::
+--identify+::
Identify {{command}}s and print in the format defined in the POSIX standard.
+-V+::
+--verbose-identify+::
Identify {{command}}s and print in a human-friendly format.
If none of the +-a+ (+--alias+), +-b+ (+--builtin-command+), +-e+
(+--external-command+), +-f+ (+--function+), and +-k+ (+--keyword+) options
is specified, the following defaults are assumed:
Without the +-v+ (+--identify+) or +-V+ (+--verbose-identify+) option::
+-b -e+
With the +-v+ (+--identify+) or +-V+ (+--verbose-identify+) option::
+-a -b -e -f -k+
[[operands]]
== Operands
{{command}}::
A command to be executed or identified.
{{argument}}...::
Arguments passed to the executed command.
[[exitstatus]]
== Exit status
The exit status of the command built-in is:
Without the +-v+ (+--identify+) or +-V+ (+--verbose-identify+) option::
the exit status of the executed command.
With the +-v+ (+--identify+) or +-V+ (+--verbose-identify+) option::
zero unless there is any error.
[[notes]]
== Notes
The command built-in is a link:builtin.html#types[mandatory built-in].
In the link:posix.html[POSIXly-correct mode], options other than +-p+, +-v+,
and +-V+ cannot be used and at most one {{command}} can be specified.
The POSIX standard does not allow specifying both +-v+ and +-V+ together, but
yash does (only the last specified one is effective).
// vim: set filetype=asciidoc textwidth=78 expandtab:
|