Why does a logical bash operator after a function call ignore errors in the function?
#!/bin/bash
set -e
echo "start script"
bad_func (){ echo 'start bad_func' ; false ; echo 'done bad_func' ; }
bad_func || { echo bad func failed ; exit 1 ; }
echo "finish script"
OUTPUT:
start script
start bad_func
done bad_func
finish script
(and script exits 0)
This works as expected if the logical operator is removed:
#!/bin/bash
set -e
echo "start script"
bad_func (){ echo 'start bad_func' ; false ; echo 'done bad_func' ; }
bad_func
echo "finish script"
OUTPUT:
start script
start bad_func
(and script exits 1)
Please supply reference to documentation when answering.
Tested with bash 5.1.12