From: Mikael Magnusson <mikachu@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Arseny Maslennikov <ar@cs.msu.ru>,
Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: 'while do done' hangs interactive zsh
Date: Sun, 16 May 2021 18:15:25 +0200 [thread overview]
Message-ID: <CAHYJk3SHxn0hdsnTfOA3c9Hj=7q-nPCVAb1MEgS9MFtu-Ea=dA@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7YDmYz8p4HwGHgbSZ0h+=OH2fztNtfZaF-t9LmSKEV=Sg@mail.gmail.com>
On 5/16/21, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Sun, May 16, 2021 at 7:28 AM Bart Schaefer <schaefer@brasslantern.com>
> wrote:
>>
>> > Even more, if the user enters "while do; done" in an interactive zsh
>> > instance, the busy loop is not interruptible by ^C, ^\ or ^Z; the shell
>> > has to be killed via some external means.
>>
>> I can NOT reproduce this in the latest revision from git, but I can
>> reproduce it in zsh-5.8.
>
> Specifically, the shell is interruptible by ^C. I haven't attempted
> to bisect where this was introduced; there are no obvious deltas to
> signals.c, loop.c, or parse.c to explain it.
I just updated to latest git and I still can't ^C the "while do;
done". I do have some local patches on top but nothing that
intentionally messes with anything related to this afaik...
> It is impossible to interrupt the parser with SIGINT. zhandler is
> entered with signal queueing enabled; when signals are allowed again,
> zhandler is called again and we pass through this code:
> 675 if (list_pipe || chline || simple_pline) {
> 676 breaks = loops;
> 677 errflag |= ERRFLAG_INT;
> 678 inerrflush();
> 679 check_cursh_sig(SIGINT);
> 680 }
> 681 lastval = 128 + SIGINT;
> Because we're still in the parser, none of (list_pipe || chline ||
> simple_pline) is true, so we never set breaks or errflag, only
> lastval. I'm not immediately sure what to do about that; perhaps just
> move the errflag setting outside that test?
>
> The attached makes both "while do" and "do done" into parse errors; I
> didn't want to try messing with the tokenizer, so better solutions are
> welcome.
I use "do done" in production code so you can't remove that. I could
imagine someone using "while do" too, but I don't so I won't complain
about that part :). It is faster to not run the builtin "true" than it
is to run it, and it has been valid syntax all these years.
> I mention tokenizing because in "for do" the string "do" is not a
> token; "while do;" could conceivably mean to execute the command "do"
> as the test condition.
--
Mikael Magnusson
next prev parent reply other threads:[~2021-05-16 16:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-16 9:16 Arseny Maslennikov
2021-05-16 14:28 ` Bart Schaefer
2021-05-16 15:46 ` Bart Schaefer
2021-05-16 16:15 ` Mikael Magnusson [this message]
2021-05-16 16:22 ` Lawrence Velázquez
2021-05-16 17:47 ` Bart Schaefer
2021-05-16 18:23 ` Martijn Dekker
2021-05-16 19:59 ` Bart Schaefer
2021-05-16 20:34 ` Peter Stephenson
2021-05-16 21:19 ` [PATCH] volatile declarations (was Re: 'while do done' hangs interactive zsh) Bart Schaefer
2021-05-16 23:40 ` Martijn Dekker
2021-05-16 16:43 ` 'while do done' hangs interactive zsh Stephane Chazelas
2021-05-16 18:02 ` Bart Schaefer
2021-05-16 18:25 ` Martijn Dekker
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='CAHYJk3SHxn0hdsnTfOA3c9Hj=7q-nPCVAb1MEgS9MFtu-Ea=dA@mail.gmail.com' \
--to=mikachu@gmail.com \
--cc=ar@cs.msu.ru \
--cc=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).