in emacs search-history mode, abort if ^@ is encountered

This has been bugging me for ages, and I finally realized it was me
accidentally pressing Ctrl+<space>, rendering ^@ (a.k.a '\0' or NUL)

Easily tested with: Ctrl+R Ctrl+<space> ...

Minimal investigation, for reference:
  bash: misbehaves in a slightly different manner
  zsh:  behaviour matches this fix

OK?

Index: emacs.c
===================================================================
RCS file: /cvs/src/bin/ksh/emacs.c,v
retrieving revision 1.88
diff -u -p -r1.88 emacs.c
--- emacs.c     27 Jun 2021 15:53:33 -0000      1.88
+++ emacs.c     13 Sep 2021 21:42:37 -0000
@@ -897,7 +897,7 @@ x_search_hist(int c)
                if ((c = x_e_getc()) < 0)
                        return KSTD;
                f = kb_find_hist_func(c);
-               if (c == CTRL('[')) {
+               if (c == CTRL('[') || c == CTRL('@')) {
                        x_e_ungetc(c);
                        break;
                } else if (f == x_search_hist)

Reply via email to