I want to write a script to display a message and possibly cancel a logout from an interactive shell. This is because I often run background jobs in some of my shells and in the spur of the moment I logout from all, closing the running jobs. What I'm after is a script like:
# If there are running jobs
if [ -z "$(jobs)" ]; then
# Display messages, give choices, etc.
...code...
# And finally, given some conditions (e.g. answers to questions, etc.)
cancel_logout
else
logout
Presumably, the above would go into ~/.bash_logout.