I have a small problem here as illustrated below. When the main program (A) call the sub program (B), B program will perform some processing. Inside program B, there is a function to perform some task C. If the conditional check is failed in function C, I will exit with exit 1 and the program will resume with the next command after the function is called. My intention is to return immediately to program A. How can I achieve that?
In program A
In program B
if (condition check)
some other processings
<note that it will still continue with above command even process_C return with exit 1>
How can it straight jump to program A once it fails in process_C? Appreciete you help...
If I understand what you are saying, exiting WILL pass control back to your calling shell (or program).
#----- prog1 ------
echo "Calling prog2 from prog1..."
echo "Back in prog1"
#----- prog2 ------
echo "In prog2Func"
echo "In prog2"
echo "You will not see this text!"
If you wanted simply to exit the function but to remain in prog2, use return.