Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: History expansion surprisingly sets event designator



On Tue, 6 Jun 2017 18:54:57 +0200
Leah Neukirchen <leah@xxxxxxxx> wrote:
> If my command line is "echo !:3" before pressing RET, it should always
> print z, even if I fiddled around with tab expansion during editing.

I see what you mean.  It's not obvious the default event propagates
from the line editor to the history line substitution performed
on input.

We can restrict the scope easily enough.

pws

diff --git a/Src/hist.c b/Src/hist.c
index 350688d..da5a8b2 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -253,6 +253,7 @@ hist_context_save(struct hist_stack *hs, int toplevel)
     hs->hwend = hwend;
     hs->addtoline = addtoline;
     hs->hlinesz = hlinesz;
+    hs->defev = defev;
     /*
      * We save and restore the command stack with history
      * as it's visible to the user interactively, so if
@@ -296,6 +297,7 @@ hist_context_restore(const struct hist_stack *hs, int toplevel)
     hwend = hs->hwend;
     addtoline = hs->addtoline;
     hlinesz = hs->hlinesz;
+    defev = hs->defev;
     if (cmdstack)
 	zfree(cmdstack, CMDSTACKSZ);
     cmdstack = hs->cstack;
diff --git a/Src/zsh.h b/Src/zsh.h
index 22f73f8..137b2a5 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -2918,6 +2918,7 @@ struct hist_stack {
     int histdone;
     int stophist;
     int hlinesz;
+    zlong defev;
     char *hline;
     char *hptr;
     short *chwords;



Messages sorted by: Reverse Date, Date, Thread, Author