The shebang doesn't cause a process to fork UNLESS the script is executable and it is invoked in such a away that it causes the system to evaluate the shebang to see what program/shell to execute the script with.
If, for instance, you were already running in bash and you executed the script with the 'source' command, then the script would be executed inside the shell you were currently running, and the exit would affect that shell process, rather than it being a new shell process which got ended.
How did you execute your script?
If you have a script file that you want to run, you should make it executable with the following command:
chmod +x script
Then if you want to run the script, and if we assume that the script file is in the current directory you use the following command:
Note that this is very different from
. script which is just shorthand notation for
./script is a relative pathname to the script file, which means search in the current directory to find the script file 'script' and then execute it -- which only works if the script file is executable.
If you have script file that is NOT executable then you can invoke it with:
But in this case you are specifying which shell to run and the shebang line is ignored.