whence command (displays how character strings would be interpreted if used as commands)
- Organization of this page
Format
whence [-p] [-v] name [name...]
Description
This command displays how specified character strings would be interpreted if used as commands. When neither option is specified, the output is as follows.
-
If a specified character string is a command, the path name of the command is output.
-
If a specified character string is an alias, the value of the alias is output.
-
If a specified character string is a reserved word, standard shell command, extended shell command, or function, the specified character string is output.
-
If none of the above applies, nothing is output and the command terminates with a return code of 1.
If the -p and -v options are both specified, the whence command assumes that a specified character string is a command and produces output accordingly. If the name argument is omitted, the command terminates with an error and returns 1 as the return code.
Arguments
- -p
-
Specifies that the specified character strings are to be handled as commands whose paths are to be output.
- -v
-
Specifies that whether each specified character string is a command, reserved-word, alias, standard shell command, extended shell command, or function is to be output.
The following table shows the contents of the output:
No.
Output contents
Meaning
1
name is a reserved word
name is a reserved word.
2
name is a function
name is a function.
3
name is a traced function
name is a function for which the trace mode is enabled.
If the function is undefined and the trace mode is enabled for it, the contents shown in No. 4 are output.
4
name is an undefined function
name is an undefined function.
5
name is an extended shell command
name is an extended shell command.
6
name is a shell builtin
name is a built-in command.
7
name is a special shell builtin
name is a special built-in command.
8
name is a shell builtin not supported
name is a command that is not provided in JP1/Advanced Shell.
9
name is path-name
name is a command or executable file.
10
name is an alias for 'alias-value'
name is an alias.
11
name is an exported alias for 'alias-value'
name is an exported alias.
12
name not found
name is not a command, reserved-word, alias, standard shell command, extended shell command, or function.
- name
-
Specifies a character string to be interpreted as a command. If this argument is omitted, the command terminates with an error and returns 1 as the return code.
Return codes
Return code |
Meaning |
---|---|
0 |
Normal termination |
1 |
Error termination. Or, one of specified character strings could not be found as a command. |
Notes
-
Even if the command syntax of this regular built-in command is incorrect, it does not exit the shell that is executing the command.
Usage example
-
Assume that pwd is a command and output its path.
Contents of the job definition script
whence -p pwd
Contents of the STDOUT file of the execution job
******** JOB SCOPE STDOUT ******** /bin/pwd