Hi searched hi and wide for this with no luck.
Maintaining a bash script that
#!/usr/bin/bash
#does some stuff like setting env etc.
f_do_dbwork
...
..
#Now I want to exit with the value of $err however $err is re-initialised to 0 on exiting the function
Always 0
....
f_do_dbwork() {
echo "$err" #- Always 0
#does a datbase call to set file that feeds the inputline command
cat $TEMP_FILE | while read inputline
do
#set variables
#call another shell script which returns an exit code of 0 or -6
$err=$?
if [ $err -ne 0 ] ; then
exit $err
fi
#more stuff
done
}
Don't have time to rewrite the cat $TEMP_FILE | while read inputline bit.
How do I get a status from the function back to the calling part of main shell script?