Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
send-break or EOF exit the shell in "vared"
- X-seq: zsh-workers 45404
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: send-break or EOF exit the shell in "vared"
- Date: Sun, 9 Feb 2020 08:33:16 +0000
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author