summaryrefslogtreecommitdiff
path: root/test/lisp/eshell/esh-var-tests.el
diff options
context:
space:
mode:
authorJim Porter <jporterbugs@gmail.com>2022-05-02 16:56:49 -0700
committerLars Ingebrigtsen <larsi@gnus.org>2022-05-03 18:23:02 +0200
commita3a7279a4ab00be69519f98536ec75dc81217b50 (patch)
tree9f4c6349e0896be9a6bfae8dbe03d1e677c64d63 /test/lisp/eshell/esh-var-tests.el
parent06423b5d1e05d524e8e745f071cbb691b446efd2 (diff)
downloademacs-a3a7279a4ab00be69519f98536ec75dc81217b50.tar.gz
emacs-a3a7279a4ab00be69519f98536ec75dc81217b50.tar.bz2
emacs-a3a7279a4ab00be69519f98536ec75dc81217b50.zip
Improve the behavior of concatenating parts of Eshell arguments
Previously, concatenating a list to a string would first convert the list to a string. Now, the string is concatenated with the last element of the list. * lisp/eshell/esh-util.el (eshell-to-flat-string): Make obsolete. * lisp/eshell/esh-arg.el (eshell-concat, eshell-concat-1): New functions. (eshell-resolve-current-argument): Use 'eshell-concat'. * test/lisp/eshell/esh-var-tests.el (esh-var-test/interp-concat-cmd): Add check for concatenation of multiline output of subcommands. (esh-var-test/quoted-interp-concat-cmd): New test. * test/lisp/eshell/em-extpipe-tests.el (em-extpipe-test-13): Use 'eshell-concat'. * doc/misc/eshell.texi (Expansion): Document this behavior. * etc/NEWS: Announce the change (bug#55236).
Diffstat (limited to 'test/lisp/eshell/esh-var-tests.el')
-rw-r--r--test/lisp/eshell/esh-var-tests.el19
1 files changed, 17 insertions, 2 deletions
diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el
index 2ce6bb4f1ba..3f3b591c5ae 100644
--- a/test/lisp/eshell/esh-var-tests.el
+++ b/test/lisp/eshell/esh-var-tests.el
@@ -176,8 +176,17 @@
(should (equal (eshell-test-command-result "+ $(+ 1 2)$(+ 1 2) 3") 36)))
(ert-deftest esh-var-test/interp-concat-cmd ()
- "Interpolate and concat command"
- (should (equal (eshell-test-command-result "+ ${+ 1 2}3 3") 36)))
+ "Interpolate and concat command with literal"
+ (should (equal (eshell-test-command-result "+ ${+ 1 2}3 3") 36))
+ (should (equal (eshell-test-command-result "echo ${*echo \"foo\nbar\"}-baz")
+ '("foo" "bar-baz")))
+ ;; Concatenating to a number in a list should produce a number...
+ (should (equal (eshell-test-command-result "echo ${*echo \"1\n2\"}3")
+ '(1 23)))
+ ;; ... but concatenating to a string that looks like a number in a list
+ ;; should produce a string.
+ (should (equal (eshell-test-command-result "echo ${*echo \"hi\n2\"}3")
+ '("hi" "23"))))
(ert-deftest esh-var-test/interp-concat-cmd2 ()
"Interpolate and concat two commands"
@@ -326,6 +335,12 @@ inside double-quotes"
"Interpolate command result redirected to temp file inside double-quotes"
(should (equal (eshell-test-command-result "cat \"$<echo hi>\"") "hi")))
+(ert-deftest esh-var-test/quoted-interp-concat-cmd ()
+ "Interpolate and concat command with literal"
+ (should (equal (eshell-test-command-result
+ "echo \"${echo \\\"foo\nbar\\\"} baz\"")
+ "foo\nbar baz")))
+
;; Interpolated variable conversion