|
|
|
|
|
by ykonstant
598 days ago
|
|
`set -e` makes the script abort and is often used in lieu of proper error handing: set -e
command
command [fails]
command
Whether the above reports error or not depends on the command; when you have a pipeline failing in the above way, it is even sneakier: set -e
command
command | command | command [fails]
command
You are reliant on all commands in the pipeline being verbose about failure to signal error.None of the above is advisable. The advisable code is error_handler() { proper error handling; }
command || error_handler "parameter"
command || error_handler "parameter"
{ command | command | command; } || error_handler "parameter"
{
set -e
exceptional section that needs to be bailed out
set +e
}
command || error_handler "parameter"
|
|