From bacc78ec3f9d75ff242d0592b2f44484e1198801 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Tue, 15 Apr 2025 10:03:23 -0700 Subject: 53454: fix interrupt handling in savehistfile() --- ChangeLog | 4 ++++ Src/hist.c | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index eb2924d45..4b4913252 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2025-04-15 Bart Schaefer + + * 53454: Src/hist.c: fix interrupt handling in savehistfile() + 2025-04-15 Eric Cook * 53485: NEWS: update for version 5.10 diff --git a/Src/hist.c b/Src/hist.c index fa1ede3f0..00bdbb2b8 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -2838,11 +2838,12 @@ readhistfile(char *fn, int err, int readflags) */ if (uselex || remeta) freeheap(); - if (errflag & ERRFLAG_INT) { - /* Can't assume fast read next time if interrupted. */ - lasthist.interrupted = 1; + if (errflag & ERRFLAG_INT) break; - } + } + if (errflag & ERRFLAG_INT) { + /* Can't assume fast read next time if interrupted. */ + lasthist.interrupted = 1; } if (start && readflags & HFILE_USE_OPTIONS) { zsfree(lasthist.text); @@ -3108,7 +3109,9 @@ savehistfile(char *fn, int err, int writeflags) hist_ignore_all_dups |= isset(HISTSAVENODUPS); readhistfile(fn, err, 0); hist_ignore_all_dups = isset(HISTIGNOREALLDUPS); - if (histlinect) + if (errflag & ERRFLAG_INT) + ret = -1; + else if (histlinect) savehistfile(fn, err, 0); pophiststack(); -- cgit v1.2.3