From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 27561 invoked from network); 16 May 2021 16:15:42 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 16 May 2021 16:15:42 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1621181742; b=CdSpBC5duZ47QKge2z18i38d2M4TtqWnutY2oh4UHJx+cD1Yf1nfmvWzCoqki9sgH0+8ImKmtR TR+dS4c2VAmS3S1MxgM4cVs+ZJeQw4/ucdl1UYeM0SQdNm7kiZw3rG8QfRCZ/A6A5WRsubiNbL LbkZMIGbRPH/2cOmH/jrW6m0ugTJqFAjPQA8/vGqQFpqswbF8HcpYomy/YOfKDnsLFu74uVT84 OwH9EjluCJEx7k/t5oKpcs984niteb4H0TQI21bveEKuXgBCDHSzSDqHCOC857E/35Cf97PFHj E06y48DsGGFF4WfeUT+ZxAYMcu8oEosLS5RtcMl/tTxxrA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-il1-f173.google.com) smtp.remote-ip=209.85.166.173; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1621181742; bh=+8+uyaYU/N0c1Qsml4QzkgPTB2HpYm67+BPE8MAZjio=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:References: In-Reply-To:MIME-Version:DKIM-Signature:DKIM-Signature; b=FbWgD1xvKkP3nSlEiQKmeNT+C5QN64Gq3qIOboY91k85pTJpZyLR6rKSGmIff0GgW84G3CNraE oKJdsPncxPMOHsuHZ1FVkQGi+l7GXqOslv04cDDSD59dW3SsinYPfgPN0dLlOZlMnMjozOUZdi UiT7nVf1FE1lnTRqlXwquByPOv9q3fchQtMC6LRqY9O5/z/7Q7x2L/qEsAPk1auIr0BF5TQzug inUfMxvxLcA0vZXtKkpSC3DLNYhFQ2HdbyoA2XsZ70pNKk0h9GP/pBuay+DOClGb6F3d1XeYji 4uIZ8QPQvjoh1Nw3wgjSFhrjv2FP/8fpygQ8VZFWHWRFbw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:References:In-Reply-To:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=N0laNtKGlHrTaWJ180P78wfgoFVb3vA2R8EeG/vTOBM=; b=SPvIIXRI85Cpx/8sfuCDpF3R1u m1Me77YO0PvEqJVdUUNrvFYr2D0jd4mhajYMS1v8X8qwAXe1/XO1+l5C3mjDxL822WTcPr+kJkQLr JeaRecbn656l19lYQChLKargqsgWB6ZaNzufeFrRNrrP9QH2SyqvgSw6zSFXhVVGvHiupRYHLC9QQ GI2M3glnv+RiNzip/XzVCcDMKCWBnTeuAliUpQs8LwZT34R/cGBmec/4U6IoR/psA6gmIRbvCOXEI f8byz9ZJ1EiaJ9EM2CPy9GuoLc//yQA4EjRHRU1ITWNvVeQ4bG7uIuLpFFTAuUQxp8q1aWaI65u/v 4OQfzX9g==; Received: from authenticated user by zero.zsh.org with local id 1liJQc-000PNH-8N; Sun, 16 May 2021 16:15:42 +0000 Authentication-Results: zsh.org; iprev=pass (mail-il1-f173.google.com) smtp.remote-ip=209.85.166.173; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-il1-f173.google.com ([209.85.166.173]:45753) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1liJQM-000P4g-Uq; Sun, 16 May 2021 16:15:28 +0000 Received: by mail-il1-f173.google.com with SMTP id e14so3970940ils.12 for ; Sun, 16 May 2021 09:15:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=N0laNtKGlHrTaWJ180P78wfgoFVb3vA2R8EeG/vTOBM=; b=SJMqjpfqXQybEwr2ihfSTbZmoUlBDOxxTVOX3gS87IVuQIeUxm6hc9b0RMMnxxTpJx OTrcocGX9sXm77+pAPEqG3zOqkQkokBR8RumB08gagUSDEcr+gjV3OydZ3qX7AutGVl8 O/VGEaZ2ZrTiWMtroy50U0Tf26O5ngWwVBROm8BGlyyxJ4l9bVJKXRicdI1k7cs6WLHG 752/c18K1faZe8n9FMRz6q/ET4EdlCeys5WmnSnJYMg+iFVcqeINcRhlnq055BcexzNG qk4IPtPHHXecj5ZQ6Hf149dC8RAg0It6UIYsmCvnjZ/nnqlW/950BeNZWVRJwOO0bNsM QoSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=N0laNtKGlHrTaWJ180P78wfgoFVb3vA2R8EeG/vTOBM=; b=QJWoEKFlMHEYWQwwwNwIq/QI15Qu/3tC1RZ0oakbbweazdDoRmAkIzmUr8dldQTzFS FQFjMUqksIhR7XHUp6hTT2C7FQJdCtyPIm3g8O+EF7YWQmux5K4+rxZYsgmxJ7sM4DER xjDM+XqiBbbZ0OvKTRV6a4KHANwYcYhK9KS9YJGxvOr3kQ50BNc5ol3iD/80v/z8z7ev VUWySKrSSgkXONJuCSa548s6xZmEgee9ecXXPl1H6h0KtyB2G4NRAxuZzMtEvtYXkBh6 szRFbdWmT8wuSXPKiCO1NEDWrVfj5RZr85m9cC5n3Sxnqv8DlfTpK0tGUt1gn99T36Uf MODg== X-Gm-Message-State: AOAM533aKoHWNgAFXK+rnJixnvjYXHu/PQBtTM9Yr1jNfxBsbBzSG/k3 utPtdNPZLopZ7a9owMQSsd140FRPe+vCt1pygdm2Ainq X-Google-Smtp-Source: ABdhPJzyy8rpwtivfv2E11Y1TSsC952qEnpOCqWHGw6aYqYwmI6mktfGwLSIN4jRSOlut+nY6kXirBq2AEOn1ZhgpCU= X-Received: by 2002:a92:db03:: with SMTP id b3mr3140760iln.219.1621181725990; Sun, 16 May 2021 09:15:25 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4f:cc46:0:0:0:0:0 with HTTP; Sun, 16 May 2021 09:15:25 -0700 (PDT) In-Reply-To: References: From: Mikael Magnusson Date: Sun, 16 May 2021 18:15:25 +0200 Message-ID: Subject: Re: 'while do done' hangs interactive zsh To: Bart Schaefer Cc: Arseny Maslennikov , Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 48842 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On 5/16/21, Bart Schaefer wrote: > On Sun, May 16, 2021 at 7:28 AM Bart Schaefer > 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