Hi all,

when running ksh in vi-mode an empty line could be stored in history:

Steps to reproduce in command mode:

1. go history back e.g.: k
2. start editor with: v
3. delete the whole line and :wq
4. check history with fc -l

Without patch:

zarathustra:/usr/src/bin/ksh$ fc -l
2       ls -la
3       fc -l
4

With patch:

zarathustra:/usr/src/bin/ksh_new$ fc -l 
7       fc -l
8       ls -la
9       fc -l
10      ls -la


Index: history.c
===================================================================
RCS file: /cvs/src/bin/ksh/history.c,v
retrieving revision 1.84
diff -u -p -u -r1.84 history.c
--- history.c   27 Oct 2019 15:02:19 -0000      1.84
+++ history.c   26 Oct 2022 08:02:52 -0000
@@ -659,6 +659,9 @@ histsave(int lno, const char *cmd, int d
        if (ignorespace && cmd[0] == ' ')
                return;
 
+       if (strlen(cmd) == 0)
+               return;
+
        c = str_save(cmd, APERM);
        if ((cp = strrchr(c, '\n')) != NULL)
                *cp = '\0';
-- 

With kind regards / Með bestu kveðju / Mit freundlichen Grüßen

Uwe Werler

Reply via email to