Is there a way to make the shell interactive in the middle of the script?

I would like to do something like:

do lots of stuff to prepare a good environement become_interactive #wait for Ctrl-D automatically clean up 

Is this possible with bash? If not, do you see another way to do the same?

+4
source share
2 answers

The structure looks 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 
+8
source

You can call another shell in the middle of the script, but change it, for example. environmental variables would not be reflected outside of it.

+2
source

Source: https://habr.com/ru/post/1299721/


All Articles