When I run a process in Bash, I can suspend it with Ctrl-Z, but that does not seem to work for sourced scripts (
. foo.sh). Is there a way to suspend such scripts?
When you source foo.sh, Ctrl+Z (SUSP) just stops the currently executing command in foo.sh and the shell blithely carries on with the next command in foo.sh.
I don't think there's a way round this. If you want to be able to suspend the whole of foo.sh you have to be running it as a subprocess by invoking it as a command not by sourcing it.