zsh-users
 help / color / mirror / code / Atom feed
* Why Zsh doesn't warn me again?
@ 2003-12-09 15:20 DervishD
  2003-12-10  6:27 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: DervishD @ 2003-12-09 15:20 UTC (permalink / raw)
  To: Zsh Users

    Hi all :)

    If you have suspended or backgrounded jobs and try to exit the
shell, zsh warns you. According to the manual, if you issue the
'jobs' command or just try to exit again, you are not warned again,
the shell exits and the jobs are terminated (except nohupped and
disowned ones, obviously). But really, it doesn't matter what command
you issue next, if you try to exit again, you are not warned :((

    This is a problem for me, when using virtual consoles, since I
not always remember if I have suspended jobs in a certain virtual
terminal, and sometimes I hit '^D' for exiting that terminal. When
zsh warns me about suspended jobs, I must remember not to issue ^D
again in that terminal, no matter if I do more work on it. How can I
change this (without IGNORE_EOF'ing) so Zsh act like the doc says? I
mean: warn me if I have suspended jobs and warn me again if I issue
more commands except 'jobs'.

    Thanks a lot :)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/


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

* Re: Why Zsh doesn't warn me again?
  2003-12-09 15:20 Why Zsh doesn't warn me again? DervishD
@ 2003-12-10  6:27 ` Bart Schaefer
  2003-12-10 14:03   ` DervishD
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2003-12-10  6:27 UTC (permalink / raw)
  To: Zsh Users

On Dec 9,  4:20pm, DervishD wrote:
}
}     If you have suspended or backgrounded jobs and try to exit the
} shell, zsh warns you. According to the manual, if you issue the
} 'jobs' command or just try to exit again, you are not warned again,
} the shell exits and the jobs are terminated (except nohupped and
} disowned ones, obviously). But really, it doesn't matter what command
} you issue next, if you try to exit again, you are not warned :((

The manual is a little too easy to misinterpret in this instance.

Although it says "you will be warned that `You have suspended (running)
jobs'.  You may use the jobs command to see what they are.  If you do
this or immediately try to exit again, the shell will not warn you a
second time" you don't have to get the first warning before the `jobs'
command has this effect.  ANY time the `jobs' command has just been
used, zsh will exit silently at the next prompt.

As far as I can tell, that isn't specifically documented anywhere, it's
just the behavior that was considered most logical.

The second problem is that typing the EOF character (ctrl-D) is not the
same as using `exit'.  It takes at least _two_ commands after an attempt
to exit before zsh will warn you again on an EOF.  That is:

1 zsh% sleep 600 &
2 zsh% exit
  zsh: you have running jobs
3 zsh% echo not yet
  not yet
4 zsh% echo wait for it
  wait for it
5 zsh% ^D
  zsh: you have running jobs
6 zsh%

If instead you ctrl-D at prompt (4), zsh will silently exit, no matter
what command you gave at prompt (3).  However, an `exit' command at (4)
will warn you again.

This happens because EOF is interpreted earlier in the command loop,
so zsh fails to properly decrement the attempted-to-exit counter (a
global called "stopmsg" if you look at the C source).  I'd say this
is a bug.
 
} How can I change this (without IGNORE_EOF'ing) so Zsh act like the
} doc says?

Use the "stty" command to set the EOF character to something other
than ctrl-D, and then bind ^D to a function similar to this one:

    eof-or-delete-char-or-list() {
	if (( $#BUFFER == 0 )); then
	    BUFFER=exit
	    zle accept-line
	else
	    zle delete-char-or-list
	fi
    }
    zle -N eof-or-delete-char-or-list
    bindkey \^D eof-or-delete-char-or-list

If you want to be able to use ^D as EOF in external commands, use

export STTY="eof '^D'"

(Remember to change the eof character before you freeze the tty, if you
happen to be using ttyctl.)


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

* Re: Why Zsh doesn't warn me again?
  2003-12-10  6:27 ` Bart Schaefer
@ 2003-12-10 14:03   ` DervishD
  0 siblings, 0 replies; 3+ messages in thread
From: DervishD @ 2003-12-10 14:03 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

    Hi Bart :)

 * Bart Schaefer <schaefer@brasslantern.com> dixit:
> As far as I can tell, that isn't specifically documented anywhere, it's
> just the behavior that was considered most logical.

    And that's (almost) true. A bit unexpected, maybe.
 
> The second problem is that typing the EOF character (ctrl-D) is not the
> same as using `exit'.

    OK, I was supposing that the code that interpreted EOF wasn't at
the same level than the code that interpreted exit or logout, but I
wasn't sure...

> It takes at least _two_ commands after an attempt
> to exit before zsh will warn you again on an EOF.

    OK. I was testing with just one command O:)

> This happens because EOF is interpreted earlier in the command loop,
> so zsh fails to properly decrement the attempted-to-exit counter (a
> global called "stopmsg" if you look at the C source).  I'd say this
> is a bug.

    If EOF is intended as a synonim for 'exit', yes, it's a bug.
Otherwise...

> } How can I change this (without IGNORE_EOF'ing) so Zsh act like the
> } doc says?
> Use the "stty" command to set the EOF character to something other
> than ctrl-D, and then bind ^D to a function similar to this one:
[...]

    Nice, thanks, but I think I must get used to use 'exit' or
'logout' instead of EOF... It's a bad habit anyway, because sometimes
I've exited a terminal accidentally with backgrounded jobs because
I've hitted ^D twice due to a bad finger movement (a trembling
finger...). Using a command to exit is less error-prone.
 
> (Remember to change the eof character before you freeze the tty, if you
> happen to be using ttyctl.)

    Thanks :))

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/


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

end of thread, other threads:[~2003-12-10 19:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-09 15:20 Why Zsh doesn't warn me again? DervishD
2003-12-10  6:27 ` Bart Schaefer
2003-12-10 14:03   ` DervishD

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).