* [BUG] REPORTTIME parsed as 0 with error in zle widget
@ 2018-02-12 9:05 Daniel Hahler
2018-02-12 20:28 ` Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Hahler @ 2018-02-12 9:05 UTC (permalink / raw)
To: Zsh Hackers' List
[-- Attachment #1.1: Type: text/plain, Size: 788 bytes --]
Given the following zle widget:
__fsel() {
exit 130 | while read item; do
:
done
}
mywidget() {
LBUFFER="${LBUFFER}$(__fsel)"
}
zle -N mywidget
bindkey '^r' mywidget
TEST CASE:
1. source it
2. set REPORTTIME=5
3. run it (ctrl-r)
RESULT:
time gets reported, but should not
getintvalue in should_report_time returns 0, although getstrvalue(v) is "5"!
This is caused by errflag being set in matheval, which makes it return 0!
And this gets caused by "exit 130" in __fsel.
I've noticed this with fzf and its widgets, where 130 is returned when selecting nothing.
btw: for fzf it makes sense to unset REPORTTIME like it has been done recently for completion functions already.
Cheers,
Daniel.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [BUG] REPORTTIME parsed as 0 with error in zle widget
2018-02-12 9:05 [BUG] REPORTTIME parsed as 0 with error in zle widget Daniel Hahler
@ 2018-02-12 20:28 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2018-02-12 20:28 UTC (permalink / raw)
To: Zsh Hackers' List
On Mon, 12 Feb 2018 10:05:08 +0100
Daniel Hahler <genml+zsh-workers@thequod.de> wrote:
> Given the following zle widget:
> getintvalue in should_report_time returns 0, although getstrvalue(v) is "5"!
> This is caused by errflag being set in matheval, which makes it return 0!
> And this gets caused by "exit 130" in __fsel.
This is probably too deep in jobs.c for anyone to have noticed it needed
protection like a lot of other functions already have.
pws
diff --git a/Src/jobs.c b/Src/jobs.c
index fc5bfac..503618f 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -925,6 +925,7 @@ should_report_time(Job j)
struct value vbuf;
Value v;
char *s = "REPORTTIME";
+ int save_errflag = errflag;
zlong reporttime = -1;
#ifdef HAVE_GETRUSAGE
char *sm = "REPORTMEMORY";
@@ -936,12 +937,14 @@ should_report_time(Job j)
return 1;
queue_signals();
+ errflag = 0;
if ((v = getvalue(&vbuf, &s, 0)))
reporttime = getintvalue(v);
#ifdef HAVE_GETRUSAGE
if ((v = getvalue(&vbuf, &sm, 0)))
reportmemory = getintvalue(v);
#endif
+ errflag = save_errflag;
unqueue_signals();
if (reporttime < 0
#ifdef HAVE_GETRUSAGE
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-12 20:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-12 9:05 [BUG] REPORTTIME parsed as 0 with error in zle widget Daniel Hahler
2018-02-12 20:28 ` Peter Stephenson
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).