summaryrefslogtreecommitdiff
path: root/lisp/eshell
diff options
context:
space:
mode:
authorJim Porter <jporterbugs@gmail.com>2022-03-05 11:45:49 -0800
committerEli Zaretskii <eliz@gnu.org>2022-03-08 15:55:41 +0200
commit6dc51d4cca3a0507d4212616ce1b24147dee54cb (patch)
treeff2851ee5a1e38a1789866ae47f55cb59f58775f /lisp/eshell
parent58568033f4b648e0dc8d9d893ef2197aded0a69e (diff)
downloademacs-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 'lisp/eshell')
-rw-r--r--lisp/eshell/esh-var.el28
1 files changed, 16 insertions, 12 deletions
diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el
index 8746f2bb931..ca4cbd744c1 100644
--- a/lisp/eshell/esh-var.el
+++ b/lisp/eshell/esh-var.el
@@ -434,13 +434,15 @@ Possible options are:
(throw 'eshell-incomplete ?\{)
(forward-char)
(prog1
- `(eshell-convert
- (eshell-command-to-value
- (eshell-as-subcommand
- ,(let ((subcmd (or (eshell-unescape-inner-double-quote end)
- (cons (point) end)))
- (eshell-current-quoted nil))
- (eshell-parse-command subcmd)))))
+ `(eshell-apply-indices
+ (eshell-convert
+ (eshell-command-to-value
+ (eshell-as-subcommand
+ ,(let ((subcmd (or (eshell-unescape-inner-double-quote end)
+ (cons (point) end)))
+ (eshell-current-quoted nil))
+ (eshell-parse-command subcmd)))))
+ indices)
(goto-char (1+ end))))))
((eq (char-after) ?\<)
(let ((end (eshell-find-delimiter ?\< ?\>)))
@@ -464,14 +466,16 @@ Possible options are:
;; properly. See bug#54190.
(list (function (lambda ()
(delete-file ,temp))))))
- (quote ,temp)))
+ (eshell-apply-indices ,temp indices)))
(goto-char (1+ end)))))))
((eq (char-after) ?\()
(condition-case nil
- `(eshell-command-to-value
- (eshell-lisp-command
- ',(read (or (eshell-unescape-inner-double-quote (point-max))
- (current-buffer)))))
+ `(eshell-apply-indices
+ (eshell-command-to-value
+ (eshell-lisp-command
+ ',(read (or (eshell-unescape-inner-double-quote (point-max))
+ (current-buffer)))))
+ indices)
(end-of-file
(throw 'eshell-incomplete ?\())))
((looking-at (rx-to-string