Subject: 27.1; `comint-redirect-results-list-from-process' treats COMMAND as a regexp

From: Phil Sainty <[email-masked]>
Date: Sun, 2 Aug 2020 15:27:17 +1200

I encountered this when sending a COMMAND ending in a backslash
to the inferior comint process, and getting Debugger entered--Lisp error:
(invalid-regexp "Trailing backslash").

E.g. M-x comint-run RET cat RET

M-: (comint-redirect-results-list "\\" ".+" 0)

Debugger entered--Lisp error: (invalid-regexp "Trailing backslash")
  (looking-at "\\")
  (comint-redirect-results-list-from-process #<process cat> "\\" ".*" 0)
  (comint-redirect-results-list "\\" ".*" 0)
  (eval (comint-redirect-results-list "\\" ".*" 0) nil)
  (eval-expression (comint-redirect-results-list "\\" ".*" 0) nil nil 127)
  (funcall-interactively eval-expression (comint-redirect-results-list "\\" ".*" 0) nil nil 127)
  (call-interactively eval-expression nil nil)
  (command-execute eval-expression)

Patch attached.  Shall I commit this to emacs-27?

-Phil

In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2020-08-02 built on shodan
Repository revision: f54ddb0198640e38c1d34bf6031ff5117c117c85
Repository branch: emacs-27
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: Ubuntu 18.04.4 LTS

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Configured using:
 'configure --prefix=/home/phil/emacs/27.0/usr/local
 --with-x-toolkit=lucid --without-sound'

Configured features:
XAW3D XPM JPEG TIFF GIF PNG RSVG DBUS GSETTINGS GLIB NOTIFY INOTIFY
GNUTLS LIBXML2 FREETYPE HARFBUZZ XFT ZLIB TOOLKIT_SCROLL_BARS LUCID X11
XDBE XIM MODULES THREADS JSON PDUMPER LCMS2 GMP

Important settings:
  value of $LANG: en_NZ.UTF-8
  locale-coding-system: utf-8

Major mode: Dired by name

Minor modes in effect:
  show-paren-mode: t
  minibuffer-depth-indicate-mode: t
  winner-mode: t
  global-hl-line-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny format-spec rfc822 mml
mml-sec password-cache epa derived epg epg-config gnus-util rmail
rmail-loaddefs text-property-search time-date subr-x seq byte-opt gv
bytecomp byte-compile cconv mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs cl-lib sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils dired-x
easymenu paren mb-depth winner ring hl-line dired dired-loaddefs advice
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core term/tty-colors frame minibuffer cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 49706 7202)
 (symbols 48 6423 1)
 (strings 32 17502 1501)
 (string-bytes 1 554965)
 (vectors 16 9973)
 (vector-slots 8 130782 9032)
 (floats 8 29 25)
 (intervals 56 250 0)
 (buffers 1000 13))
>From be456b8592429f0542113e0a433a6b977135d094 Mon Sep 17 00:00:00 2001
From: Phil Sainty <[email-masked]>
Date: Sun, 2 Aug 2020 13:03:27 +1200
Subject: [PATCH] Fix usage of literal text as regexp

* lisp/comint.el (comint-redirect-results-list-from-process):
Use 'regexp-quote' when checking whether literal string COMMAND
was inserted into the buffer.
---
 lisp/comint.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/comint.el b/lisp/comint.el
index bf376a0..3e76c5d 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -3835,7 +3835,7 @@ comint-redirect-results-list-from-process
       (set-buffer output-buffer)
       (goto-char (point-min))
       ;; Skip past the command, if it was echoed
-      (and (looking-at command)
+      (and (looking-at (regexp-quote command))
 	   (forward-line))
       (while (and (not (eobp))
 		  (re-search-forward regexp nil t))
-- 
2.8.3