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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7920 invoked from network); 27 Apr 2021 21:35:46 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 27 Apr 2021 21:35:46 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1619559346; b=HtO9O5Jpb3avIh/SVMF99lC+MRcCVRpnZC3SY0ivP8g5RIWUzYRB8ia90w2czhdexQwIUJFIcV trywU01KuQz9833ED8BBEVQgpslGi5ohjshmb8vL/c6VxtGnDAr3vzxdfLfGyicPgcSQCWtaxD DOChLe2oHkjeuxBnc3N+JCppGMX9AyqMObpuJ9OiYFLM5yWZa3AXTNMkLiHNG+R4P+VR9vtnuK zV6xRZuwqsRa2rzLbGmgnIkGMu/On0EnmkF7FUt+p5dalI+4SXCU2GKwyqetGhIYof/niNze7K T+qkrbZXjrix0J0jEB749fDCdhCprnaB3yYuVxu13zoHYA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ot1-f44.google.com) smtp.remote-ip=209.85.210.44; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1619559346; bh=gIqvLxAaQe4YeYaMNbzPu2gxu8OAudUeBoRr4Dy4u+g=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:MIME-Version: DKIM-Signature:DKIM-Signature; b=q7P2PYfT7wdmeaNFeyZEfcceoV5FEz5WzoH/GNPmWJoEmAbRlYk5Ot+SdFYSsEWcYYVlXYUZGT 8u+A0LK+1RbMyBvH+P7i8Ugt0t95VkJGsBaVoAwxXJE8svArs0cYWfoOKfLyCbpcv10NTnVGY5 M07BY+szktfiYkATHxjvcFDSo2AzLvCCmemT6U7/fgLkghVaXF/PfY/4mnpBRrvK+TLYDPFCng iSGz23Qq2IPJA9TS9+AgLlOJEIFRLpYxivXKltGquTv9hv4UOByqpLfJ1FNX2TWPEUtsIqR43t JcoiFSYheDlodBxd8efVHGGljq1vDSbivqI4kHp1bpAs7A==; 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:To:Subject:Message-ID: Date:From:MIME-Version:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=Y3RlMahS347t+65FRSDg+uogQHBelAPht4zcHX3dzuc=; b=ISmK9++6VdX5RYbW9vM4vLhCH9 3U1GqTmXuy8l3KirBcxuTJ1XZmuT7FQ8dH6lNoSlf7NA7LwL6hKReBL+D40VG5XDMbXAeAybFFfFk EKApIq/KqnGicmA90FzWDYRkHAPp+ltRg2o98V3DOtcIkf84pDpysTl14sf5TmOUI+ZHYyEyZHHhV P1yLc30M2372PMucLItRyrvGjENnaDAy7bKjjP2hbrRIT30HHS4+D9GwM8pq4a/k7T/Wb5X3zgc7/ MXFVf8npeDvRg2tur8SjP9aBzcOUJ/4bQxVbCz+pDmwtegbVaCt2N22rwasBp3+7rrCWhCEYucr9R o9zxp8Wg==; Received: from authenticated user by zero.zsh.org with local id 1lbVMs-000Jgu-9b; Tue, 27 Apr 2021 21:35:42 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ot1-f44.google.com) smtp.remote-ip=209.85.210.44; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ot1-f44.google.com ([209.85.210.44]:46075) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lbVMc-000JTB-Kr; Tue, 27 Apr 2021 21:35:27 +0000 Received: by mail-ot1-f44.google.com with SMTP id f75-20020a9d03d10000b0290280def9ab76so51523110otf.12 for ; Tue, 27 Apr 2021 14:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=Y3RlMahS347t+65FRSDg+uogQHBelAPht4zcHX3dzuc=; b=NEn87jLQlZi6oT8MC/fO2AUTdFJ8CFY3aI+mgIzXmqEFT8BDcQHNeEIPivMyH9rMY/ 0RZEMPqDfp9q0HepE1YvJ4QNqIK3r4ZH8ghBVKlGQxPFY/IjLZ2JX/MK4Jvd+kkkunqm E/3OtVw5L/YLMgm8JbRICWclLO9nuRZIXuAJYxUDjv+Eqn2bMe2TDn/WBInY/nsb2el+ jCfbnKwaAZ8KbHHsMStUxQ+g+R06PlhSIN/i21xAwDOBAxSIEiH/iT0fq2cYCxRn6ivd x43GOgvVuvJnZNIMBDlQt0GpkVgberb5q+fo6mb5vyyCVHOfTwmJZe/IaL1FxQgr6h/Z Vcgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Y3RlMahS347t+65FRSDg+uogQHBelAPht4zcHX3dzuc=; b=PgGlltnDs6uZJS1gi/U/nGaCpDZGV4fJ7sNsiiEMaIarRbjMOQ/UAW4Xf9B9ZIArGa aaiciDBjXuH0vHJ8dV1XQi6+NDltUpRxi6d+plwGidLLkStSdJ09KmUgZhmkddI9f3Hq UcCXY1AVQW9anVBR2IhkSkNaZktwXaDoB3BK4qqUal+PAJnzSoSYcWwU4zNh19V/XsVl yK+9uASHiJEZJnIaxHbMrMV1+e30l/MdDNvqwnvNVDon4ubxID6fre0pZndjZy1xmnS0 oPDrMoI6/+lRzJOGGluRzixVxGw4UpLI1DvqQn9vn+Nl20pijwJJ9s3Y1eMn3b0Nj943 A1mQ== X-Gm-Message-State: AOAM5305HKi3KruRj/rlCFLjAhZi27xMhYexrz85oNMBD+3O5ffS+HNT U64teyageMSG+7GJ4NeOuUgQXkrP1V7kKlXqXTuGUvRiR7oBtA== X-Google-Smtp-Source: ABdhPJyDyHTUbGSf4whvym+HFsQF49l3mM9MN+f6ysJrzdkesNvxaXDx1LyPKDk3g7z4MZtYYYY9+GaDHDaN3xf5srI= X-Received: by 2002:a9d:a4e:: with SMTP id 72mr20937049otg.229.1619559325241; Tue, 27 Apr 2021 14:35:25 -0700 (PDT) MIME-Version: 1.0 From: Bart Schaefer Date: Tue, 27 Apr 2021 14:35:14 -0700 Message-ID: Subject: The curious incident of the feep in the night-time To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 48734 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: Starting from a fresh zsh -f: % yy() { zle .send-break } % zle -N yy % 12345 (type ESC x yy RET, note that prompt silently returns) % On every subsequent invocation of yy, you'll get a beep ... until a command at the prompt exits zero, and then just one following invocation of yy will be silent again. The problem is that lastval is never updated when execzlefunc() returns nonzero from the nested call (first call is to yy, nested call is to .send-break), so eventually execpline() returns the old lastval to the outer execzlefunc(), which behaves as if yy succeeded and therefore skips handlefeep(). The inner execzlefunc() is called from bin_zle_call() and the outer one from zlecore(). I think it's correct that the inner one does not handlefeep() [if it did, you'd feep twice] but something needs to set lastval. Further complicating this is that execcmd_exec() skips setting lastval when ERRFLAG_INT is set, which is one of the bits used by sendbreak(). That's why the old value is still present when the outer execzlefunc() returns. 4139 /* 4140 * In case of interruption assume builtin status 4141 * is less useful than what interrupt set. 4142 */ 4143 if (!(errflag & ERRFLAG_INT)) 4144 lastval = ret; (indentation munged by copy-pasting tabs). The reference to "what interrupt set" seems to imply that it is sendbreak() that should be assigning lastval, because it is simulating a SIGINT and the handler for SIGINT assigns lastval directly. What eventually does set lastval = 1 is the parser noticing that the lexer failed on the interrupt. Once that happens, further widget calls don't reset it, so the feeps occur. The other question is, to what should lastval be set? Is there reliance on it being 1 here? (The parser only changes it [to 1] when it is already 0.) (For those confused about the Subject, see https://en.wikipedia.org/wiki/The_Adventure_of_Silver_Blaze)