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.
This commit is contained in:
Jim Porter 2024-10-20 15:02:18 -07:00
parent 75fa0cc1ae
commit 183c5efc0f
2 changed files with 5 additions and 3 deletions

View 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)

View 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"