cat >file1.sh <<'EOF_FILE1'
echo 'before source'
source 'file2.sh'
echo 'after source'
func1
EOF_FILE1
cat >file2.sh <<'EOF_FILE2'
echo 'test script'
func1() {
echo 'func1 starts'
exit
}
exit
EOF_FILE2
bash file1.sh
Intended output is:
before source
test script
after source
func1 starts
Actual output is:
before source
test script
The 'after source' is missing due to the exit command. Is there a way around this since I can not remove exit from the code?