How are you calling second.sh in first.sh? If you are using one of these:
Code:
. second.sh
source second.sh
... that would explain the behavior. sourcing or executing with the dot notation means "read the contents of this file and execute it in the current shell". Thus, when "exit" is called, the first (only) shell will exit.
If you're using exec, then that will also exhibit the same behaviour, because the exec command means "replace the current process with this command", and at that point, your origial script goes away, never to be returned to.
What you probably want to do is execute second.sh in a sub-shell. If you have set the permissions so the file is executable, you can just use the path to the file like this:
Code:
./second.sh # if it's in the present working directory
/path/to/second.sh # if you prefer to specify full path
second.sh # if the location is somewhere in the PATH
The caveat is that a sub-process cannot modify the environment of the parent. If you need to do this you can pass output on stdout, or can source a file which defines functions, which you can then execute in the "parent" script.