aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorSean Whitton2022-04-02 16:08:41 +0200
committerLars Ingebrigtsen2022-04-02 16:08:41 +0200
commit02ef00d89c64d713f29f4ed12dbcae9f8d31bb9a (patch)
tree6ab04d444de9548c34af9aa36e94e4c6447bbbc5 /lisp
parent6dc4e3b95ca9589f24530979cdc83ea346d1ca45 (diff)
downloademacs-02ef00d89c64d713f29f4ed12dbcae9f8d31bb9a.tar.gz
emacs-02ef00d89c64d713f29f4ed12dbcae9f8d31bb9a.zip
em-extpipe: Catch eshell-incomplete thrown while parsing
* lisp/eshell/em-extpipe.el (em-extpipe--or-with-catch): New macro. (eshell-parse-external-pipeline): Use new macro to treat `eshell-incomplete' as a failure of the parse function to move us forward (Bug#54603). Thanks to Jim Porter <jporterbugs@gmail.com> for the report and for help isolating the problem. * test/lisp/eshell/eshell-tests.el (eshell-test/lisp-command-with-quote): New test for Bug#54603, thanks to Jim Porter <jporterbugs@gmail.com> (bug#54603).
Diffstat (limited to 'lisp')
-rw-r--r--lisp/eshell/em-extpipe.el22
1 files changed, 18 insertions, 4 deletions
diff --git a/lisp/eshell/em-extpipe.el b/lisp/eshell/em-extpipe.el
index eb5b3bfe1df..3db1dea5955 100644
--- a/lisp/eshell/em-extpipe.el
+++ b/lisp/eshell/em-extpipe.el
@@ -49,6 +49,19 @@
49 (add-hook 'eshell-pre-rewrite-command-hook 49 (add-hook 'eshell-pre-rewrite-command-hook
50 #'eshell-rewrite-external-pipeline -20 t)) 50 #'eshell-rewrite-external-pipeline -20 t))
51 51
52(defmacro em-extpipe--or-with-catch (&rest disjuncts)
53 "Evaluate DISJUNCTS like `or' but catch `eshell-incomplete'.
54
55If `eshell-incomplete' is thrown during the evaluation of a
56disjunct, that disjunct yields nil."
57 (let ((result (gensym)))
58 `(let (,result)
59 (or ,@(cl-loop for disjunct in disjuncts collect
60 `(if (catch 'eshell-incomplete
61 (ignore (setq ,result ,disjunct)))
62 nil
63 ,result))))))
64
52(defun eshell-parse-external-pipeline () 65(defun eshell-parse-external-pipeline ()
53 "Parse a pipeline intended for execution by the external shell. 66 "Parse a pipeline intended for execution by the external shell.
54 67
@@ -105,10 +118,11 @@ as though it were Eshell syntax."
105 (if (re-search-forward pat next t) 118 (if (re-search-forward pat next t)
106 (throw 'found (match-beginning 1)) 119 (throw 'found (match-beginning 1))
107 (goto-char next) 120 (goto-char next)
108 (while (or (eshell-parse-lisp-argument) 121 (while (em-extpipe--or-with-catch
109 (eshell-parse-backslash) 122 (eshell-parse-lisp-argument)
110 (eshell-parse-double-quote) 123 (eshell-parse-backslash)
111 (eshell-parse-literal-quote))) 124 (eshell-parse-double-quote)
125 (eshell-parse-literal-quote)))
112 ;; Guard against an infinite loop if none of 126 ;; Guard against an infinite loop if none of
113 ;; the parsers moved us forward. 127 ;; the parsers moved us forward.
114 (unless (or (> (point) next) (eobp)) 128 (unless (or (> (point) next) (eobp))