diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | Src/hist.c | 13 | ||||
-rw-r--r-- | Src/zsh.h | 1 |
3 files changed, 20 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog index 3037edda4..31b0dea64 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2018-01-24 Peter Stephenson <p.stephenson@samsung.com> + + * 42322 (tweaked): Src/hist.c, Src/zsh.h: don't discard a + history line with just an interactive comment simply because + there were no words, since the comment now doesn't produce + words. + 2018-01-23 Barton E. Schaefer <schaefer@zsh.org> * Joey Pabalinas: 42313: Src/subst.c: avoid null-pointer deref diff --git a/Src/hist.c b/Src/hist.c index e08984f00..b798be8e4 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -204,6 +204,13 @@ int hlinesz; static zlong defev; +/* + * Flag that we stopped reading line when we got to a comment, + * but we want to keep it in the histofy even if there were no words + * (i.e. the comment was the entire line). + */ +static int hist_keep_comment; + /* Remember the last line in the history file so we can find it again. */ static struct histfile_stats { char *text; @@ -258,6 +265,7 @@ hist_context_save(struct hist_stack *hs, int toplevel) hs->addtoline = addtoline; hs->hlinesz = hlinesz; hs->defev = defev; + hs->hist_keep_comment = hist_keep_comment; /* * We save and restore the command stack with history * as it's visible to the user interactively, so if @@ -303,6 +311,7 @@ hist_context_restore(const struct hist_stack *hs, int toplevel) addtoline = hs->addtoline; hlinesz = hs->hlinesz; defev = hs->defev; + hist_keep_comment = hs->hist_keep_comment; if (cmdstack) zfree(cmdstack, CMDSTACKSZ); cmdstack = hs->cstack; @@ -1462,7 +1471,7 @@ hend(Eprog prog) } else save = 0; } - if (chwordpos <= 2) + if (chwordpos <= 2 && !hist_keep_comment) save = 0; else if (should_ignore_line(prog)) save = -1; @@ -1565,6 +1574,7 @@ hend(Eprog prog) */ while (histsave_stack_pos > stack_pos) pophiststack(); + hist_keep_comment = 0; unqueue_signals(); return !(flag & HISTFLAG_NOEXEC || errflag); } @@ -1591,6 +1601,7 @@ ihwabort(void) { if (chwordpos%2) chwordpos--; + hist_keep_comment = 1; } /* add a word to the history List */ diff --git a/Src/zsh.h b/Src/zsh.h index ba2f8cd9f..8b4898477 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -2997,6 +2997,7 @@ struct hist_stack { void (*addtoline) _((int)); unsigned char *cstack; int csp; + int hist_keep_comment; }; /* |