2 Answers
2

In the case of your particular script, neither Myscript nor command D will ever be executed. You've defined a function C, but you aren't calling it.

The order of execution is:

command B runs to completion.

command E runs to completion.

If you were to call C, it would run Myscript to completion, then run command D to completion.

Everything you invoke in a shell script runs in the order it's seen, and runs to completion. If you need to run something in parallel with something else, you should use job control (check out how the ampersand & character is used to put jobs in the background). A quick example:

A
B

Runs A until it's done, then runs B until it's done. The script finishes.

A &
B

Runs A in the background, then runs B in the foreground. The shell script ends when B has completed. A may still be running.

A &
B &

Runs A in the background, then (without waiting for A to complete), runs B in the background. The script ends immediately.

A &
B &
wait

Runs A in the background, then (without waiting for A to complete), runs B in the background. The script then waits for both A and B to complete before exiting.

There is an exception which will be detailed later, but those commands are executed by the same shell (even if Myscript opens a new shell, it and command D will possess exactly the same "mother" shell that runs them). Because *NIX shells don't support parallelization, Myscript has to stop its run (with any exit codes) to let the control got by command D.

The exception is the case where you are detaching Myscript, with a NOHUP signal, or by writing a & behind Myscript. This will put the script to the background.

Study the following code snippet:

openssl enc -e bf -in verybigfile -out outputfile -k thisismykey &; # this is a long operation because of the size of the very big file
echo 'hi!' # this will be written during the encrypting operation

I hope this is almost self-explanatory now.

The answer of Alexios contains a great point: you don't call the function, so it will never run.