From 690bc445774832564e59d4ba8d5988e0fb8cf611 Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Sun, 20 Oct 2024 15:02:18 -0700 Subject: [PATCH] Be more careful about applying spliced arguments 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 | 2 +- test/lisp/eshell/esh-var-tests.el | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index c9096b0d159..137abe6eb75 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -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) diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el index 70f6e9c7777..38f90e615a8 100644 --- a/test/lisp/eshell/esh-var-tests.el +++ b/test/lisp/eshell/esh-var-tests.el @@ -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" -- 2.39.2