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?
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?
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.
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