Edit: If I can use return
instead, what about functions that use set -e
?
I run screen on my Linux VM in order to have multiple terminals that I can disconnect from and return to when I want.
I'm having issues with running bash commands that use functions that either directly call exit
or have set -e
in them - they cause the screen terminal to close and kick me out to another one of my screen terminals.
Is there a way to get screen to stop responding to exit
calls, or perhaps make it aware that the exit
is purely for the return value of the function that's using it?
The offending function:
function unpackdb() {
cd $DB_LOCATION
mkdir -p downloads
cd downloads
db_file_name=$(ls -t *.tar.gz 2> /dev/null | head -1)
if [ -n "$db_file_name" ] ; then
tar xf $db_file_name -C ../data
echo "Latest file (${db_file_name}) restored in to ${pwd}/../data"
else
echo "Could not find a .tar.gz in ${pwd}, if you don't care use command 'startdb'"
exit 1
fi
}