Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
RE: checking jobs when zsh exits
- X-seq: zsh-users 2806
- From: Alan Iwi <iwi@xxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxxxxxx
- Subject: RE: checking jobs when zsh exits
- Date: Fri, 24 Dec 1999 15:32:14 +0000 (GMT)
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
- Reply-to: Alan Iwi <iwi@xxxxxxxxxxxx>
tjlists@xxxxxxxxxxx wrote:
> Also, fyi, the zsh-user@xxxxxxxxxxxxxxx address is obsolete...
Okay, thanks. I've got myself onto the list now, so I'll stay subscribed
for at least long enough to catch any replies (longer if I get keen :-)).
> Here's my hack-script, which I call "jobout" and then have:
> alias x='source jobout'
Thanks very much.
Sorry, I'd failed to mention I've already got a hack (some lines in .zshrc)
so that just typing "exit" does approximately the desired thing. I was
just a bit unsure about posting code to the list, but in case it's useful
here it is (see below). It works, but it would be nice to avoid hackiness.
Happy Christmas.
Alan
#----------------------------------------------------------------------
disown_running()
{
# disown running jobs
tmpfile==(:)
jobs -r > $tmpfile
running=`awk '{gsub("[][]","",$1);print "%"$1}' < $tmpfile`
if [ -n "$running" ] ; then disown $running; fi
# check for remaining jobs
jobs >! $tmpfile
[ -z "`<$tmpfile`" ] ; retval=$?
/bin/rm $tmpfile
# returns 1 if jobs still remaining, else 0
return $retval
}
if [ "$PS1" != "" ]
then
exit()
{
disown_running && builtin exit "$@"
echo "You have stopped jobs:"
jobs
select name in 'exit anyway' 'return to prompt'
do
case $name in
'exit anyway')
builtin exit "$@"
;;
'return to prompt')
return
;;
esac
done
}
fi
alias logout='exit'
#----------------------------------------------------------------------
Messages sorted by:
Reverse Date,
Date,
Thread,
Author