How to disable set -e and set -o

Viewed 6564

So I have this at the start of a bash script file (-e and -o). However, in some functions, I would like for it to not exit out. Example

set -e
set -o pipefail

function check_status {
    echo "Start Check"
    docker exec mservice bash -c "echo 'Hello' | grep 'fail'"
    echo "End check"
}

check_status

How can I prevent this from exiting out of the script - basically if I run this, it would printout "Start Check", but then exit because the next command returns a '1'.

I would like to be able to disable and enable the set -e/-o in multiple places or in different functions.

2 Answers
Related