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 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 10665 invoked from network); 29 Nov 2022 10:14:26 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 29 Nov 2022 10:14:26 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1669716866; b=bpj+97WNPuDeSOtH0WNFrdifFWg20XB1z1fjObI3acEvS3R6XRgbjSR+22uIl+ypx3ys5C+dxc STRiA/HOfZ4WkjbTrjKPf4g8K9158bzyWjdW2lH6CkKTgTJAJXbzCJQBnXbd2xHaC1FldQ1VWD 7x3eBq/9Cdd6FeCkBRyvRivOFFKHTYryTfWIl2U+mzV93PGuFOGewdaf09PjxaQO8Cq6jT+tLK Quu5GZhgzKXFUNtIt1Co6bpnE+CwfadraF7V51sN08S1AcMusy8gGMGqPQ7ssHOY3OO71QkAo5 QXvePaPHlxjW3a4dyBtzafs2UL1L1L8r/htIYNb72BA+GA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yb1-f176.google.com) smtp.remote-ip=209.85.219.176; dkim=pass header.d=gmail.com header.s=20210112 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-20210803; t=1669716866; bh=+0ALc8meBmUVzc59ihNiDacywNqkndFDl0u+UgpdOpA=; 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:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=g18fkf3fqdKMqzTEtnQvSKNM5a7E+SsgyQwRao2ci82w1EIQMPSVtXG6SG3QjT3JmTWR1r0PFj QI8feYyPgB3bokSHUJS7p5D16oXsNOlga392+3Zkhk12/QSS5pck9UMJmCEVdVcm2Li3ujlDaQ jXMsDUVHgZy+LDe4ob+emx9vAOlaiNYs4xGG3jRX718yZonPQGjFap0elxrU5j1byZZI/P5x1O OuhjmufhXyhpRGkW+g3jTaiLpo4m4llwxNR1UZGf0Fi562Y15+v3wTkTnRQeB2K4QAiB+G+aod a71K68ORVyxNVDzPWmq5KkS27tJ4+t4vtfGF+F3D36xYMA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; 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:In-Reply-To:References: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=F1Cy6v/TceZzmvgPPmihuXc/SxXYGeb8ngHTAVqS6wE=; b=E7HCqfjhOhI75+zVqzw0BlR4Dz bK1mtwYwRw3KCGwPdB2GWLolHASI3tnqBTH27Uu14oFg/EE5GyCAMdEmTBRJqN3r7cV0RQfPk/UXB E3s8gl4QPCCgCxUbkH3L0mEK7DYCSNEKbLavFLyzVzxjQQakmwaOQkNMhyT+EXCBdgPI80btxKNLF CnzCmy3Zuls39NjMvSqnR6XMQfB7vwyaun7COHAWETaRfZaAdxdcIyk3BEQEKTZ5M2Q5ExOdr8i1j qfv+PQLVImCdPm9Lg4gAGPKR+SS0fv49bQCBMkcmKnfeV+PLUaUL1C6EnwmjjycuUz1Hz8XvVpz5Z hWtld3eA==; Received: by zero.zsh.org with local id 1ozxdA-0003vD-Nv; Tue, 29 Nov 2022 10:14:24 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yb1-f176.google.com) smtp.remote-ip=209.85.219.176; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-yb1-f176.google.com ([209.85.219.176]:45999) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1ozxcP-0003Gr-3J; Tue, 29 Nov 2022 10:13:37 +0000 Received: by mail-yb1-f176.google.com with SMTP id y83so16796749yby.12 for ; Tue, 29 Nov 2022 02:13:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=F1Cy6v/TceZzmvgPPmihuXc/SxXYGeb8ngHTAVqS6wE=; b=UumS5Sj1HgfJhFFQq05r88kzVyn0QWMTPhQXC7z1BEN0M6IGtp0wTn8a9JlsIlM4X0 kHuERyALW2KcwlxMl93jy5P0nDLKrIH0Lydc/RygccsebQXXEnHDyMPs10o5I0shCINB 6VgI4BJGpb7gtRxYcZ58A0Mbtf1hiRjHBUCkGi6pfVVUoPADeXEGIdEt+8g8EeB81ySd OSTV1Od/AgTUWzrQbbm6Cq+P3mwcAzIT58t4rDqqpuik/YfF1gvKdwneNkAE2DAthuMS nATCCKhL8hF+jv9RwipzENo6/ft5WGeQE7p3Nx6k3mOj4jrdwzvr84I8oab/B4n0AdX2 joLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=F1Cy6v/TceZzmvgPPmihuXc/SxXYGeb8ngHTAVqS6wE=; b=k3ho2HHkF8TmSfGnZxWs4Cqu7AYp+j9msxpltzdwicCf9syRttGmada7Tk4an7ASsn 8uIFST+QJob7puxRLsFS0WQBqCIHM0wNmw5uETqGCHC64pBqOm58YJRSqoHbj8kq1KLA SR/1hm8bZm4V8yCekCoRPCKrYi2ukMyH7SSBX1rzp9br1ovIiiheikM2uiiBIswDDAge w5pl8YV4GIFeopDe1j/M7xdTiy4PBneaakP1nrz5qVf0N9nKzVSkd2VPs8xtUImRRGko Gd9As51tkhaTqW7ygb9lb3QAxCNr+zm5rvH0WWMu7H/mhE8zVFq91lkKjx4kTmWNlN3u arQA== X-Gm-Message-State: ANoB5pmFSMDHT62M6Emg7nL0xBtvd6zxV+vH37I3a/VSa+On3KDanS7H 3fLuZKQMF19d2/Gk8+PXBI1N9n+0Eh6eTNcGeDc= X-Google-Smtp-Source: AA0mqf56k70uGVRnTOiIOLTOzNhcZrYmMGBqtSkna2FFZJ6RifZJg/vjVeNTZTd8kVS0OY6qx2CajeCoD8rpkDvdus0= X-Received: by 2002:a25:d1cf:0:b0:6f4:265f:ece2 with SMTP id i198-20020a25d1cf000000b006f4265fece2mr16269724ybg.175.1669716815745; Tue, 29 Nov 2022 02:13:35 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Roman Perepelitsa Date: Tue, 29 Nov 2022 11:13:24 +0100 Message-ID: Subject: Re: one time in 20 error To: Risto Laitinen Cc: Ray Andrews , Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 28447 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Tue, Nov 29, 2022 at 3:49 AM Risto Laitinen wrote: > > It is a mouse event (SGR report mode) Thanks! So here's what's probably happening. The script is enabling mouse tracking, the user clicks with the mouse, the script disables mouse tracking and exits before reading the mouse event, zle reads the mouse event. The script needs to read from the TTY after disabling mouse tracking. Reading with timeout is suboptimal because there is no upper bound on input latency (imagine working over SSH). A better solution is to send a query and read the response. Something like this perhaps: function cleanup() { emulate -L zsh -o extended_glob # Disable mouse tracking. print -n '\e[?1000l' # Disable SGR mouse mode. print -n '\e[?1006l' # Query the TTY (Primary Device Identification). print -n '\e[0c' # Read stdin until we find the response to our query. local resp while [[ $resp != *$'\e[?'(<->\;)#<->c ]] && read -skr 'resp[$#resp+1]'; do # Do nothing. done } This function needs to be invoked before the script exits. There is probably a better solution to this problem. Roman. P.S. I have the following in my .zshrc: function skip-csi-sequence() { local key while read -sk key && (( $((#key)) < 0x40 || $((#key)) > 0x7E )); do # empty body done } zle -N skip-csi-sequence bindkey '\e[' skip-csi-sequence With this binding a buggy script that leaks mouse events into zle won't have any effect.