zsh-users
 help / color / mirror / code / Atom feed
* checking jobs when zsh exits
@ 1999-12-24 12:48 Alan Iwi
  1999-12-24 14:37 ` TjL
  1999-12-24 22:09 ` Peter Stephenson
  0 siblings, 2 replies; 5+ messages in thread
From: Alan Iwi @ 1999-12-24 12:48 UTC (permalink / raw)
  To: zsh-users


During a discussion about zsh on a local newsgroup, someone suggested I
should post this here as a feature request.

When trying to exit from zsh you are warned about running or stopped jobs,
whereas tcsh and bash behaviour is to only warn you about _stopped_ jobs,
not _running_ jobs.  I think this distinction is valid, as stopped jobs are
typically likely to be stuff which writes to the terminal (e.g. a gdb
session which you've suspended) whereas running jobs are often X programs
which can carry on fine without the invoking shell (e.g. emacs window).

Rather than having to remember to type stuff like "emacs &!" instead of
"emacs &" every time, would it be possible to add a new option which makes
zsh warn about stopped jobs but not running jobs on exit, like other shells?

Many thanks.

Alan


P.S. I am not on the mailing list myself - I know it's polite to subscribe
to a list before posting to it, but here's what happened when I tried, so
please CC: me any replies - thanks!

    ... while talking to math.gatech.edu.:
    >>> RCPT To:<zsh-users-request@math.gatech.edu>
    <<< 550 <zsh-users-request@math.gatech.edu>... User unknown


^ permalink raw reply	[flat|nested] 5+ messages in thread
* RE: checking jobs when zsh exits
@ 1999-12-24 15:32 Alan Iwi
  1999-12-24 16:48 ` Alan Iwi
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Iwi @ 1999-12-24 15:32 UTC (permalink / raw)
  To: zsh-users

tjlists@bigfoot.com wrote:

> Also, fyi, the zsh-user@math.gatech.edu 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'
#----------------------------------------------------------------------



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1999-12-24 22:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-24 12:48 checking jobs when zsh exits Alan Iwi
1999-12-24 14:37 ` TjL
1999-12-24 22:09 ` Peter Stephenson
1999-12-24 15:32 Alan Iwi
1999-12-24 16:48 ` Alan Iwi

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).