I have a unix korn script that executes another script. If the called script detects an error it does an exit or exit 1. This does not return to the calling script. How do I code the script to return regardless of what happens in the calling script.
Script A
. ${path}/script_B
Script_B
echo 'This is executed from script_A'
if [ -e ${path}/goodfile ]
then
echo 'File exists'
else
echo 'when I do this exit it does not go back to script_A'
exit 1
fi
if [ -e ${path}/badfile ]
then
echo 'when I do this exit it does not go back to script_A'
exit 2
fi
echo 'If it comes here it will return to script_A'
Script A
. ${path}/script_B
Script_B
echo 'This is executed from script_A'
if [ -e ${path}/goodfile ]
then
echo 'File exists'
else
echo 'when I do this exit it does not go back to script_A'
exit 1
fi
if [ -e ${path}/badfile ]
then
echo 'when I do this exit it does not go back to script_A'
exit 2
fi
echo 'If it comes here it will return to script_A'