From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 242e5481 for ; Sun, 9 Feb 2020 08:34:02 +0000 (UTC) Received: (qmail 15004 invoked by alias); 9 Feb 2020 08:33:57 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45404 Received: (qmail 1940 invoked by uid 1010); 9 Feb 2020 08:33:57 -0000 X-Qmail-Scanner-Diagnostics: from relay5-d.mail.gandi.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25713. spamassassin: 3.4.2. Clear:RC:0(217.70.183.197):SA:0(-2.6/5.0):. Processed in 1.284454 secs); 09 Feb 2020 08:33:57 -0000 X-Envelope-From: stephane@chazelas.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _nblcust.gandi.net designates 217.70.183.197 as permitted sender) X-Originating-IP: 2.127.75.28 Date: Sun, 9 Feb 2020 08:33:16 +0000 From: Stephane Chazelas To: Zsh hackers list Subject: send-break or EOF exit the shell in "vared" Message-ID: <20200209083316.axjj6nf7hndb7wqw@chazelas.org> Mail-Followup-To: Zsh hackers list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: NeoMutt/20180716 For context, that's still about trying to answer that "how to add a timeout to `vared`" question at https://unix.stackexchange.com/questions/565718/zsh-timeout-for-vared-builtin I was thinking: vared uses zle, zle is fully programmable, that shouldn't be too difficult. But so far I've not been able to do it without a subshell and I ran in a few unexpected behaviours. In: 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 With: 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" That is where a read() on the terminal will return 0 (EOF) if nothing is entered within a second, the shell exits as well (with status 1) not just vared, the "always" block is not run. Same with vared -e. My other approaches trying to use TMOUT and a SIGALRM trap or a zle -F handler that invokes send-break or accept-line (or queues ^G/^M with zle -U) haven't been successful either (either exit the shell or don't exit zle straight away or at all). -- Stephane