diff options
author | Jim Porter <jporterbugs@gmail.com> | 2022-03-05 11:45:49 -0800 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2022-03-08 15:55:41 +0200 |
commit | 6dc51d4cca3a0507d4212616ce1b24147dee54cb (patch) | |
tree | ff2851ee5a1e38a1789866ae47f55cb59f58775f /test/lisp/eshell/esh-var-tests.el | |
parent | 58568033f4b648e0dc8d9d893ef2197aded0a69e (diff) | |
download | emacs-6dc51d4cca3a0507d4212616ce1b24147dee54cb.tar.gz emacs-6dc51d4cca3a0507d4212616ce1b24147dee54cb.tar.bz2 emacs-6dc51d4cca3a0507d4212616ce1b24147dee54cb.zip |
Support applying indices to more Eshell dollar expansions
For example, '${echo -e "hi\nbye"}[1]' should expand to "bye".
* lisp/eshell/esh-var.el (eshell-parse-variable-ref): Support applying
indices to '${}', '$()', and '$<>' forms.
(Bug#54227)
* lisp/eshell/esh-var-tests.el (esh-var-test/interp-lisp-indices)
(esh-var-test/interp-cmd-indices)
(esh-var-test/interp-cmd-external-indices)
(esh-var-test/quoted-interp-lisp-indices)
(esh-var-test/quoted-interp-cmd-indices): New tests.
Diffstat (limited to 'test/lisp/eshell/esh-var-tests.el')
-rw-r--r-- | test/lisp/eshell/esh-var-tests.el | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el index d09dd614de8..1d051d681af 100644 --- a/test/lisp/eshell/esh-var-tests.el +++ b/test/lisp/eshell/esh-var-tests.el @@ -137,10 +137,18 @@ "Interpolate Lisp form evaluation" (should (equal (eshell-test-command-result "+ $(+ 1 2) 3") 6))) +(ert-deftest esh-var-test/interp-lisp-indices () + "Interpolate Lisp form evaluation with index" + (should (equal (eshell-test-command-result "+ $(list 1 2)[1] 3") 5))) + (ert-deftest esh-var-test/interp-cmd () "Interpolate command result" (should (equal (eshell-test-command-result "+ ${+ 1 2} 3") 6))) +(ert-deftest esh-var-test/interp-cmd-indices () + "Interpolate command result with index" + (should (equal (eshell-test-command-result "+ ${list 1 2}[1] 3") 5))) + (ert-deftest esh-var-test/interp-cmd-external () "Interpolate command result from external command" (skip-unless (executable-find "echo")) @@ -148,6 +156,13 @@ (eshell-command-result-p "echo ${*echo hi}" "hi\n"))) +(ert-deftest esh-var-test/interp-cmd-external-indices () + "Interpolate command result from external command with index" + (skip-unless (executable-find "echo")) + (with-temp-eshell + (eshell-command-result-p "echo ${*echo \"hi\nbye\"}[1]" + "bye\n"))) + (ert-deftest esh-var-test/interp-temp-cmd () "Interpolate command result redirected to temp file" (should (equal (eshell-test-command-result "cat $<echo hi>") "hi"))) @@ -282,12 +297,20 @@ inside double-quotes" "echo \"hi $(concat \\\"the\\\" \\\"re\\\")\"") "hi there"))) +(ert-deftest esh-var-test/quoted-interp-lisp-indices () + "Interpolate Lisp form evaluation with index" + (should (equal (eshell-test-command-result "+ \"$(list 1 2)[1]\" 3") 5))) + (ert-deftest esh-var-test/quoted-interp-cmd () "Interpolate command result inside double-quotes" (should (equal (eshell-test-command-result "echo \"hi ${echo \\\"there\\\"}\"") "hi there"))) +(ert-deftest esh-var-test/quoted-interp-cmd-indices () + "Interpolate command result with index inside double-quotes" + (should (equal (eshell-test-command-result "+ \"${list 1 2}[1]\" 3") 5))) + (ert-deftest esh-var-test/quoted-interp-temp-cmd () "Interpolate command result redirected to temp file inside double-quotes" (should (equal (eshell-test-command-result "cat \"$<echo hi>\"") "hi"))) |