mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-19 23:41:31 +01:00
dc517212ca
Don't behave as if command not found if return status is non-zero as this may simply be the return status of the replacement command. Let the function report a command not found instead.
38 lines
1.7 KiB
Text
38 lines
1.7 KiB
Text
texinode(Command Execution)(Functions)(Redirection)(Top)
|
|
chapter(Command Execution)
|
|
ifzman(\
|
|
sect(Command Execution)
|
|
)\
|
|
cindex(command execution)
|
|
cindex(execution, of commands)
|
|
cindex(command not found, handling of)
|
|
findex(command_not_found_handler)
|
|
If a command name contains no slashes, the shell attempts to locate
|
|
it. If there exists a shell function by that name, the function
|
|
is invoked as described in noderef(Functions). If there exists
|
|
a shell builtin by that name, the builtin is invoked.
|
|
|
|
vindex(path, use of)
|
|
Otherwise, the shell searches each element of tt($path) for a
|
|
directory containing an executable file by that name. If the
|
|
search is unsuccessful, the shell prints an error message and returns
|
|
a nonzero exit status.
|
|
|
|
If execution fails because the file is not in executable format,
|
|
and the file is not a directory, it is assumed to be a shell
|
|
script. tt(/bin/sh) is spawned to execute it. If the program
|
|
is a file beginning with `tt(#!)', the remainder of the first line
|
|
specifies an interpreter for the program. The shell will
|
|
execute the specified interpreter on operating systems that do
|
|
not handle this executable format in the kernel.
|
|
|
|
If no external command is found but a function tt(command_not_found_handler)
|
|
exists the shell executes this function with all
|
|
command line arguments. The return status of the function becomes the
|
|
status of the command. If the function wishes to mimic the
|
|
behaviour of the shell when the command is not found, it should
|
|
print the message `tt(command not found:) var(cmd)' to standard error
|
|
and return status 127. Note that the handler is executed in a
|
|
subshell forked to execute an external command, hence changes to
|
|
directories, shell parameters, etc. have no effect on the main shell.
|
|
|