I'd like to do something like:
do lots of stuff to prepare a good environement
become_interactive
#wait for Ctrl-D
automatically clean up
Is it possible with bash? If not, do you see another way of doing the same thing?
Structure it like this:
test.sh
#!/bin/sh
exec bash --rcfile environ.sh
environ.sh
cleanup() {
echo "Cleaning up"
}
trap cleanup EXIT
echo "Initializing"
PS1='>> '
In action:
~$ ./test.sh
Initializing
>> exit
Cleaning up
You can invoke another shell in the middle of the script, but changes to e.g. environment variables would not be reflected outside of it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With