установка или отключение опций и позиционных параметров (set or unset options and positional parameters)
Использование в приложениях (Application usage)
Application writers should avoid relying on set -e
within
functions. For example, in the following script:
set -e
start() {
some_server
echo some_server started successfully
}
start || echo >&2 some_server failed
the -e
setting is ignored within the function body (because the
function is a command in an AND-OR list other than the last).
Therefore, if some_server fails, the function carries on to echo
"some_server
startedsuccessfully"
, and the exit status of the
function is zero (which means "some_server
failed" is not output).