I use bash shell script in my project.
Main script call many sub scripts, but sometimes sub script has error. I want script stop immediately.
I found -errexit
option. It will works for me.
There are constraints. I can't edit sub scripts. plus, i don't want to touch exec line.
Lower is example.
#!/bin/bash
# do something
exec bash test.sh
test.sh
#!/bin/bash
cat as.txt # error
cat ab.txt # run
I want cat ab.txt
not be run.
I know, exex bash -e test.sh
will run.
but real project code is this, touch exec line is dangerous.
exec "$@"
I can't expect what is $@
.
If i write set -e
in 'do something', it's not apply in child process(test.sh).
I can change default option script, like ~/.bashrc
?
How can i apply shell option for child process?
Please help me!
This is the solution.
export SHELLOPTS
This answer helped me.
https://unix.stackexchange.com/questions/387186/are-all-the-shell-options-not-inherited-by-scripts