]> git.eshelyaron.com Git - emacs.git/commitdiff
Be more careful about applying spliced arguments
authorJim Porter <jporterbugs@gmail.com>
Sun, 20 Oct 2024 22:02:18 +0000 (15:02 -0700)
committerEshel Yaron <me@eshelyaron.com>
Tue, 22 Oct 2024 19:01:58 +0000 (21:01 +0200)
Previously, this could 'nonc' to a list that shouldn't be modified.

* lisp/eshell/esh-cmd.el (eshell-rewrite-named-command): Use 'append'
instead of 'nconc'.

* test/lisp/eshell/esh-var-tests.el (esh-var-test/interp-var-splice):
(esh-var-test/quoted-interp-var-splice): New tests.

(cherry picked from commit 183c5efc0fe80074a40ebebb684d787baf578ffe)

lisp/eshell/esh-cmd.el
test/lisp/eshell/esh-var-tests.el

index c9096b0d159da700da7c219d33303644222c82a9..137abe6eb7598fa0aee46f41053fb6c72744c6e5 100644 (file)
@@ -488,7 +488,7 @@ command hooks should be run before and after the command."
           (grouped-terms (eshell-prepare-splice terms)))
       (cond
        (grouped-terms
-        `(let ((new-terms (nconc ,@grouped-terms)))
+        `(let ((new-terms (append ,@grouped-terms)))
            (,sym (car new-terms) (cdr new-terms))))
        ;; If no terms are spliced, use a simpler command form.
        ((cdr terms)
index 70f6e9c777786abc81761b32b2252d6f1be55129..38f90e615a89abdef80f75c66658ec74a648708e 100644 (file)
@@ -217,7 +217,8 @@ nil, use FUNCTION instead."
   "Splice-interpolate list variable."
   (let ((eshell-test-value '(1 2 3)))
     (eshell-command-result-equal "echo a $@eshell-test-value z"
-                                 '("a" 1 2 3 "z"))))
+                                 '("a" 1 2 3 "z"))
+    (should (equal eshell-test-value '(1 2 3)))))
 
 (ert-deftest esh-var-test/interp-var-splice-concat ()
   "Splice-interpolate and concat list variable."
@@ -428,7 +429,8 @@ nil, use FUNCTION instead."
   "Splice-interpolate list variable inside double-quotes."
   (let ((eshell-test-value '(1 2 3)))
     (eshell-command-result-equal "echo a \"$@eshell-test-value\" z"
-                                 '("a" "1 2 3" "z"))))
+                                 '("a" "1 2 3" "z"))
+    (should (equal eshell-test-value '(1 2 3)))))
 
 (ert-deftest esh-var-test/quoted-interp-var-splice-concat ()
   "Splice-interpolate and concat list variable inside double-quotes"