diff options
| author | Jim Porter | 2024-10-20 15:02:18 -0700 |
|---|---|---|
| committer | Jim Porter | 2024-10-20 18:03:45 -0700 |
| commit | 183c5efc0fe80074a40ebebb684d787baf578ffe (patch) | |
| tree | 1ab41f5a7a9d206dee0823ccd7341060186a3ef2 | |
| parent | 75fa0cc1ae2b53fe169fdcfef52bee6719eb38a7 (diff) | |
| download | emacs-183c5efc0fe80074a40ebebb684d787baf578ffe.tar.gz emacs-183c5efc0fe80074a40ebebb684d787baf578ffe.zip | |
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.
| -rw-r--r-- | lisp/eshell/esh-cmd.el | 2 | ||||
| -rw-r--r-- | 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." | |||
| 488 | (grouped-terms (eshell-prepare-splice terms))) | 488 | (grouped-terms (eshell-prepare-splice terms))) |
| 489 | (cond | 489 | (cond |
| 490 | (grouped-terms | 490 | (grouped-terms |
| 491 | `(let ((new-terms (nconc ,@grouped-terms))) | 491 | `(let ((new-terms (append ,@grouped-terms))) |
| 492 | (,sym (car new-terms) (cdr new-terms)))) | 492 | (,sym (car new-terms) (cdr new-terms)))) |
| 493 | ;; If no terms are spliced, use a simpler command form. | 493 | ;; If no terms are spliced, use a simpler command form. |
| 494 | ((cdr terms) | 494 | ((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." | |||
| 217 | "Splice-interpolate list variable." | 217 | "Splice-interpolate list variable." |
| 218 | (let ((eshell-test-value '(1 2 3))) | 218 | (let ((eshell-test-value '(1 2 3))) |
| 219 | (eshell-command-result-equal "echo a $@eshell-test-value z" | 219 | (eshell-command-result-equal "echo a $@eshell-test-value z" |
| 220 | '("a" 1 2 3 "z")))) | 220 | '("a" 1 2 3 "z")) |
| 221 | (should (equal eshell-test-value '(1 2 3))))) | ||
| 221 | 222 | ||
| 222 | (ert-deftest esh-var-test/interp-var-splice-concat () | 223 | (ert-deftest esh-var-test/interp-var-splice-concat () |
| 223 | "Splice-interpolate and concat list variable." | 224 | "Splice-interpolate and concat list variable." |
| @@ -428,7 +429,8 @@ nil, use FUNCTION instead." | |||
| 428 | "Splice-interpolate list variable inside double-quotes." | 429 | "Splice-interpolate list variable inside double-quotes." |
| 429 | (let ((eshell-test-value '(1 2 3))) | 430 | (let ((eshell-test-value '(1 2 3))) |
| 430 | (eshell-command-result-equal "echo a \"$@eshell-test-value\" z" | 431 | (eshell-command-result-equal "echo a \"$@eshell-test-value\" z" |
| 431 | '("a" "1 2 3" "z")))) | 432 | '("a" "1 2 3" "z")) |
| 433 | (should (equal eshell-test-value '(1 2 3))))) | ||
| 432 | 434 | ||
| 433 | (ert-deftest esh-var-test/quoted-interp-var-splice-concat () | 435 | (ert-deftest esh-var-test/quoted-interp-var-splice-concat () |
| 434 | "Splice-interpolate and concat list variable inside double-quotes" | 436 | "Splice-interpolate and concat list variable inside double-quotes" |