]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix input of sharp-quoted symbols in Eshell with em-extpipe
authorSean Whitton <spwhitton@spwhitton.name>
Wed, 26 Jan 2022 13:13:00 +0000 (14:13 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 26 Jan 2022 13:16:40 +0000 (14:16 +0100)
* lisp/eshell/em-extpipe.el (eshell-parse-external-pipeline): Fix
misinterpreting sharp-quoted symbols as the beginning of single-quoted
strings (Bug#53518).  Add protection against a possible infinite loop.
* test/lisp/eshell/em-extpipe-tests.el (em-extpipe-test-17): New
test (bug#53518).

lisp/eshell/em-extpipe.el
test/lisp/eshell/em-extpipe-tests.el

index 57aeec38ff657ee631beabd6b4b62742b7aa28e5..eb5b3bfe1df447c165d241a3e2a3b6bc3cde0254 100644 (file)
@@ -30,6 +30,7 @@
 
 (require 'cl-lib)
 (require 'esh-arg)
+(require 'esh-cmd)
 (require 'esh-io)
 (require 'esh-util)
 
@@ -97,15 +98,21 @@ as though it were Eshell syntax."
                    (while (> bound (point))
                      (let* ((found
                              (save-excursion
-                               (re-search-forward "['\"\\]" bound t)))
+                               (re-search-forward
+                                "\\(?:#?'\\|\"\\|\\\\\\)" bound t)))
                             (next (or (and found (match-beginning 0))
                                       bound)))
                        (if (re-search-forward pat next t)
                            (throw 'found (match-beginning 1))
                          (goto-char next)
-                         (while (or (eshell-parse-backslash)
+                         (while (or (eshell-parse-lisp-argument)
+                                    (eshell-parse-backslash)
                                     (eshell-parse-double-quote)
-                                    (eshell-parse-literal-quote)))))))))
+                                    (eshell-parse-literal-quote)))
+                         ;; Guard against an infinite loop if none of
+                         ;; the parsers moved us forward.
+                         (unless (or (> (point) next) (eobp))
+                           (forward-char 1))))))))
            (goto-char (if (and result go) (match-end 0) start))
            result)))
     (unless (or eshell-current-argument eshell-current-quoted)
index 1283b6b361f120a375fe62723a692110ad27d1ba..0879ad5b0cac6a322f6ff0f4958e47c097c1babb 100644 (file)
       (eshell-command-result-p input "rab")
       (eshell-command-result-p "echo \"bar\" | rev" "nonsense"))))
 
+;; Confirm we don't break input of sharp-quoted symbols (Bug#53518).
+(em-extpipe-tests--deftest em-extpipe-test-17 "funcall #'upcase foo"
+  (eshell-command-result-p input "FOO"))
+
 ;;; em-extpipe-tests.el ends here