[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 0a79e28891: Reset 'eshell-in-pipeline-p' when interpolating comma
From: |
Lars Ingebrigtsen |
Subject: |
master 0a79e28891: Reset 'eshell-in-pipeline-p' when interpolating commands |
Date: |
Wed, 25 May 2022 08:13:42 -0400 (EDT) |
branch: master
commit 0a79e28891ec7394547358207a8213a7c457a592
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Reset 'eshell-in-pipeline-p' when interpolating commands
* lisp/eshell/esh-cmd.el (eshell-subcommand-bindings)
(eshell-command-to-value): Set 'eshell-in-pipeline-p' to nil.
* test/lisp/eshell/eshell-tests.el
(eshell-test/subcommand-reset-in-pipeline)
(eshell-test/lisp-reset-in-pipeline): New tests (bug#55620).
---
lisp/eshell/esh-cmd.el | 4 +++-
test/lisp/eshell/eshell-tests.el | 29 +++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el
index 73c250632c..775e4c1057 100644
--- a/lisp/eshell/esh-cmd.el
+++ b/lisp/eshell/esh-cmd.el
@@ -256,6 +256,7 @@ the command."
(defcustom eshell-subcommand-bindings
'((eshell-in-subcommand-p t)
+ (eshell-in-pipeline-p nil)
(default-directory default-directory)
(process-environment (eshell-copy-environment)))
"A list of `let' bindings for subcommand environments."
@@ -907,7 +908,8 @@ This avoids the need to use `let*'."
(defmacro eshell-command-to-value (object)
"Run OBJECT synchronously, returning its result as a string.
Returns a string comprising the output from the command."
- `(let ((value (make-symbol "eshell-temp")))
+ `(let ((value (make-symbol "eshell-temp"))
+ (eshell-in-pipeline-p nil))
(eshell-do-command-to-value ,object)))
;;;_* Iterative evaluation
diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el
index c0affed80a..ab5d73d479 100644
--- a/test/lisp/eshell/eshell-tests.el
+++ b/test/lisp/eshell/eshell-tests.el
@@ -130,6 +130,35 @@ e.g. \"{(+ 1 2)} 3\" => 3"
(eshell-command-result-p "echo ${*echo hi | *cat} | *cat"
"hi")))
+(ert-deftest eshell-test/subcommand-reset-in-pipeline ()
+ "Check that subcommands reset `eshell-in-pipeline-p'."
+ (skip-unless (executable-find "cat"))
+ (dolist (template '("echo {%s} | *cat"
+ "echo ${%s} | *cat"
+ "*cat $<%s> | *cat"))
+ (should (equal (eshell-test-command-result
+ (format template "echo $eshell-in-pipeline-p"))
+ nil))
+ (should (equal (eshell-test-command-result
+ (format template "echo | echo $eshell-in-pipeline-p"))
+ "last"))
+ (should (equal (eshell-test-command-result
+ (format template "echo $eshell-in-pipeline-p | echo"))
+ "first"))
+ (should (equal (eshell-test-command-result
+ (format template
+ "echo | echo $eshell-in-pipeline-p | echo"))
+ "t"))))
+
+(ert-deftest eshell-test/lisp-reset-in-pipeline ()
+ "Check that interpolated Lisp forms reset `eshell-in-pipeline-p'."
+ (skip-unless (executable-find "cat"))
+ (dolist (template '("echo (%s) | *cat"
+ "echo $(%s) | *cat"))
+ (should (equal (eshell-test-command-result
+ (format template "format \"%s\" eshell-in-pipeline-p"))
+ "nil"))))
+
(ert-deftest eshell-test/redirect-buffer ()
"Check that piping to a buffer works"
(with-temp-buffer
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 0a79e28891: Reset 'eshell-in-pipeline-p' when interpolating commands,
Lars Ingebrigtsen <=