I am trying to make a "toolkit", and what I want is for it to have an "exit" functionality. Meaning that whenever I invoke "exit", whatever I have started should stop. However, not just the toolkit script, but the main script as well. Meaning the following:
Let A.sh be the master script. At some point, A.sh will trigger B.sh, which gives the user options. I want B.sh to always have an "exit" option. When chosen, it should exit B.sh (easy, just run "exit"), but also end A.sh.
Of course, I could do something like
if [[ $(B.sh) == "exit" ]]; then exit; fi
but that is tedious at best, and generally not what a "toolkit" should do.
Any ideas how I can do it? Cheers.
B.sh
:my_B() { if [[ $(B.sh) == "exit" ]]; then exit; fi; }
. Or source it, if every timeB.sh
exits you want A.sh to exit too.A.sh
to "trigger"B.sh
. There are many ways to do it, and it's hard giving you a generic answer. It's also likely to be a programming question, not a Unix one.