diff options
author | Peter Stephenson <pws@zsh.org> | 2013-10-11 11:13:03 +0100 |
---|---|---|
committer | Peter Stephenson <pws@zsh.org> | 2013-10-11 11:13:03 +0100 |
commit | d0fe73c5fb87ff8388837a508b903f7e93b0b2c0 (patch) | |
tree | aec6a5956070320ea729d48c3887065ca9b4fff7 | |
parent | c35a561a9c0ea5f3190141c7ccf28720c100485a (diff) | |
download | zsh-d0fe73c5fb87ff8388837a508b903f7e93b0b2c0.tar.gz zsh-d0fe73c5fb87ff8388837a508b903f7e93b0b2c0.tar.xz zsh-d0fe73c5fb87ff8388837a508b903f7e93b0b2c0.zip |
31815: another fix for INCAPPENDHISTORY change.
We need to save immediately if something is pushed on the history stack to ensure we use the right file before popping.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Src/hist.c | 17 |
2 files changed, 20 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog index 524f54242..f9b765aca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-10-11 Peter Stephenson <p.stephenson@samsung.com> + + * 31815: Src/hist.c: more fallout from 31789: we need to save + using pushed history file before we pop. + 2013-10-10 Peter Stephenson <p.stephenson@samsung.com> * 31810: Test/E02xtrace.ztst: tests for simple cases of XTRACE diff --git a/Src/hist.c b/Src/hist.c index bd650e81e..ed9560952 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -937,12 +937,21 @@ hbegin(int dohist) /* * For INCAPPENDHISTORY, when interactive, save the history here * as it gives a better estimate of the times of commands. + * * If SHAREHISTORY is also set continue to do so in the * standard place, because that's safer about reading and * rewriting history atomically. + * + * The histsave_stack_pos test won't usually fail here. + * We need to test the opposite for the hend() case because we + * need to save in the history file we've switched to, but then + * we pop immediately after that so the variable becomes zero. + * We will already have saved the line and restored the history + * so that (correctly) nothing happens here. But it shows + * I thought about it. */ if (isset(INCAPPENDHISTORY) && !isset(SHAREHISTORY) && - !(histactive & HA_NOINC) && !strin) + !(histactive & HA_NOINC) && !strin && histsave_stack_pos == 0) savehistfile(hf, 0, HFILE_USE_OPTIONS | HFILE_FAST); } @@ -1348,7 +1357,11 @@ hend(Eprog prog) chline = hptr = NULL; chwords = NULL; histactive = 0; - if (isset(SHAREHISTORY) && histfileIsLocked()) + /* + * For normal INCAPPENDHISTORY case and reasoning, see hbegin(). + */ + if (isset(SHAREHISTORY) ? histfileIsLocked() : + (isset(INCAPPENDHISTORY) && histsave_stack_pos != 0)) savehistfile(hf, 0, HFILE_USE_OPTIONS | HFILE_FAST); unlockhistfile(hf); /* It's OK to call this even if we aren't locked */ /* |