From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29301 invoked from network); 10 Dec 2003 06:27:26 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 10 Dec 2003 06:27:26 -0000 Received: (qmail 21461 invoked by alias); 10 Dec 2003 06:27:12 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6856 Received: (qmail 21451 invoked from network); 10 Dec 2003 06:27:12 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 10 Dec 2003 06:27:12 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [4.11.8.53] by sunsite.dk (MessageWall 1.0.8) with SMTP; 10 Dec 2003 6:27:11 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id hBA6R9L28622 for zsh-users@sunsite.dk; Tue, 9 Dec 2003 22:27:09 -0800 X-Authentication-Warning: candle.brasslantern.com: schaefer set sender to schaefer@closedmail.com using -f From: Bart Schaefer Message-Id: <1031210062709.ZM28621@candle.brasslantern.com> Date: Wed, 10 Dec 2003 06:27:09 +0000 In-Reply-To: <20031209152026.GA4153@DervishD> Comments: In reply to DervishD "Why Zsh doesn't warn me again?" (Dec 9, 4:20pm) References: <20031209152026.GA4153@DervishD> X-Mailer: Z-Mail (5.0.0 30July97) To: Zsh Users Subject: Re: Why Zsh doesn't warn me again? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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.)