* send-break or EOF exit the shell in "vared"
@ 2020-02-09 8:33 Stephane Chazelas
2020-02-09 9:09 ` Stephane Chazelas
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Stephane Chazelas @ 2020-02-09 8:33 UTC (permalink / raw)
To: Zsh hackers list
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: send-break or EOF exit the shell in "vared"
2020-02-09 8:33 send-break or EOF exit the shell in "vared" Stephane Chazelas
@ 2020-02-09 9:09 ` Stephane Chazelas
2020-02-10 17:03 ` Sebastian Gniazdowski
2020-06-10 0:53 ` Bart Schaefer
2 siblings, 0 replies; 4+ messages in thread
From: Stephane Chazelas @ 2020-02-09 9:09 UTC (permalink / raw)
To: Zsh hackers list
2020-02-09 08:33:16 +0000, Stephane Chazelas:
[...]
> zsh -c 'vared -c foo; echo $? $foo'
>
> If I press ^G (send-break widget), that exits the shell (with
> status 0), not just "vared".
[...]
Looks like a regression. That changed in 5.0.8, 5.0.7 was fine.
git bisect points at: https://www.zsh.org/mla/workers/2015/msg00843.html
which was about avoiding syntax error messages upon ^C/^G/push-input.
Setting the "continueonerror" option doesn't help.
doc says:
send-break (^G ESC-^G) (unbound) (unbound)
Abort the current editor function, e.g. execute-named-command, or
the editor itself, e.g. if you are in vared. Otherwise abort the
parsing of the current line; in this case the aborted line is
available in the shell variable ZLE_LINE_ABORTED. If the editor is
aborted from within vared, the variable ZLE_VARED_ABORTED is set.
So it is indeed a bug.
I suppose there's also the question of what push-line,
push-input should do in vared.
--
Stephane
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: send-break or EOF exit the shell in "vared"
2020-02-09 8:33 send-break or EOF exit the shell in "vared" Stephane Chazelas
2020-02-09 9:09 ` Stephane Chazelas
@ 2020-02-10 17:03 ` Sebastian Gniazdowski
2020-06-10 0:53 ` Bart Schaefer
2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Gniazdowski @ 2020-02-10 17:03 UTC (permalink / raw)
To: Zsh hackers list
[-- Attachment #1: Type: text/plain, Size: 913 bytes --]
On Sun, 9 Feb 2020 at 09:34, Stephane Chazelas <stephane@chazelas.org>
wrote:
> 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".
>
I've had a somewhat similar problem:
https://www.zsh.org/mla/workers/2019/msg00721.html
--
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zinit
<https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin>
Blog: http://zdharma.org
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: send-break or EOF exit the shell in "vared"
2020-02-09 8:33 send-break or EOF exit the shell in "vared" Stephane Chazelas
2020-02-09 9:09 ` Stephane Chazelas
2020-02-10 17:03 ` Sebastian Gniazdowski
@ 2020-06-10 0:53 ` Bart Schaefer
2 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2020-06-10 0:53 UTC (permalink / raw)
To: Zsh hackers list
Happened upon this while reviewing something else ...
On Sun, Feb 9, 2020 at 12:34 AM Stephane Chazelas <stephane@chazelas.org> wrote:
>
> 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
Looking at this a bit more closely, ^G is treated as an interrupt
here. This solves the issue:
zsh -c '{ vared -c a; } always {
TRY_BLOCK_INTERRUPT=0;
echo in always; }; echo $? $a'
However, an actual interrupt with ^C will still exit the whole shell,
in that specific example.
> 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"
This is an entirely different case. zle_main.c:getbyte() calls
zexit() directly if raw_getbyte() returns zero. This is probably a
bug, or it at least should be documented that when ZLE receives EOF it
behaves as if "exit" had been called. IGNORE_EOF will cause it to
retry 20 times, but it never stops getting EOF because the tty has in
fact closed the descriptor.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-06-10 0:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-09 8:33 send-break or EOF exit the shell in "vared" Stephane Chazelas
2020-02-09 9:09 ` Stephane Chazelas
2020-02-10 17:03 ` Sebastian Gniazdowski
2020-06-10 0:53 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).