Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable set -e and set -o

Tags:

People also ask

How do you remove a set from a set in Python?

Python Set remove() MethodThe remove() method removes the specified element from the set. This method is different from the discard() method, because the remove() method will raise an error if the specified item does not exist, and the discard() method will not.

How do you remove an element from a set in C++?

set::erase() erase() function is used to remove elements from a container from the specified position or range.


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.