zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: send-break or EOF exit the shell in "vared"
Date: Tue, 9 Jun 2020 17:53:51 -0700	[thread overview]
Message-ID: <CAH+w=7Z6E+=aO_05qE0tqMfh1GH3JgHLVk7jbo=JyoqxfScvKg@mail.gmail.com> (raw)
In-Reply-To: <20200209083316.axjj6nf7hndb7wqw@chazelas.org>

Happened upon this while reviewing something else ...

On Sun, Feb 9, 2020 at 12:34 AM Stephane Chazelas <stephane@chazelas.org> wrote:
>
> zsh -c 'vared -c foo; echo $? $foo'
>
> If I press ^G (send-break widget), that exits the shell (with
> status 0), not just "vared".
>
> With:
>
> zsh -c '{ vared -c a; } always { TRY_BLOCK_ERROR=0; echo in always; }; echo $? $a'
>
> Upon ^G, the "always" block is run, but that still exits the
> shell (with status 2 this time) despite the TRY_BLOCK_ERROR=0

Looking at this a bit more closely, ^G is treated as an interrupt
here.  This solves the issue:

zsh -c '{ vared -c a; } always {
  TRY_BLOCK_INTERRUPT=0;
  echo in always; }; echo $? $a'

However, an actual interrupt with ^C will still exit the whole shell,
in that specific example.

> zle-line-init() stty -icanon time 10 min 0 <&2
> zle -N zle-line-init
> {
>   vared -c var
> } always {
>   TRY_BLOCK_ERROR=0
>   print in always
> }
> echo "$? $var"

This is an entirely different case.  zle_main.c:getbyte() calls
zexit() directly if raw_getbyte() returns zero.  This is probably a
bug, or it at least should be documented that when ZLE receives EOF it
behaves as if "exit" had been called. IGNORE_EOF will cause it to
retry 20 times, but it never stops getting EOF because the tty has in
fact closed the descriptor.

      parent reply	other threads:[~2020-06-10  0:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-09  8:33 Stephane Chazelas
2020-02-09  9:09 ` Stephane Chazelas
2020-02-10 17:03 ` Sebastian Gniazdowski
2020-06-10  0:53 ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7Z6E+=aO_05qE0tqMfh1GH3JgHLVk7jbo=JyoqxfScvKg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).