I work with several systems created from bash scripts and other tools. Quite often, I find it good practice to use the -e, -u, and -o pipefail options to detect errors and prevent unexpected behavior.
However, some of the third-party libraries (to which I have the opportunity to change the source) do not, and are not happy with the change in the variable existence tests with -u.
Scenarios in them most likely will not be received. So what I would like to do in some of them, set a more permissive set of parameters, and then restore more stringent ones. Since the scenarios in question are used by many users, some of whom also faced the same problem, I would like to make this change in third-party scripts, that is:
<preserve original options> set +e +u +o pipefail #do stuff like if [ -n "$_UNSET_VAR" ] ; then cp <some stuff> <some other stuff> fi <restore original options (whatever they were)>
I am looking for ways to save and restore these originals.
source share