I'm writing a shell function that will be called from many different places and I want to ignore all errors occurring inside the function disabling the (possibly enabled) set -e
shell option, executing set +e
.
The problem is that I don't know if that option was set or not, so I don't know if it's really needed to disable it, and more important, if I need to set it again at the end.
So, how do I know if it is set or not? Is there any way to ignore errors of all commands inside a shell function ignoring the -e
shell option if is set?