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() --- Src/hist.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'Src') 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