diff options
author | Jim Porter <jporterbugs@gmail.com> | 2022-07-09 16:26:55 -0700 |
---|---|---|
committer | Jim Porter <jporterbugs@gmail.com> | 2022-09-04 15:15:01 -0700 |
commit | ab7e94fb1d9b794c9d199435d72f569fba6ab017 (patch) | |
tree | bdb8f5d264c9377c519ccc61009a4d9ab9551be0 /lisp/eshell/esh-arg.el | |
parent | 3d6c013a27e0b72c8fbe2d47f752dd0dfd4ff47a (diff) | |
download | emacs-ab7e94fb1d9b794c9d199435d72f569fba6ab017.tar.gz emacs-ab7e94fb1d9b794c9d199435d72f569fba6ab017.tar.bz2 emacs-ab7e94fb1d9b794c9d199435d72f569fba6ab017.zip |
Add support for more kinds of redirect operators in Eshell
* lisp/eshell/esh-arg.el: Require cl-lib.
(eshell-finish-arg): Allow passing multiple ARGUMENTS.
(eshell-quote-argument): Handle the case when 'eshell-finish-arg' was
passed multiple arguments.
* lisp/eshell/esh-cmd.el (eshell-do-pipelines)
(eshell-do-pipelines-synchronously): Only set stdout output handle.
* lisp/eshell/esh-io.el (eshell-redirection-operators-alist): New
constant.
(eshell-io-initialize): Prefer sharp quotes for functions.
(eshell-parse-redirection, eshell-strip-redirections): Add support for
more redirection forms.
(eshell-copy-output-handle, eshell-set-all-output-handles): New
functions.
* test/lisp/eshell/esh-io-tests.el
(esh-io-test/redirect-all/overwrite, esh-io-test/redirect-all/append)
(esh-io-test/redirect-all/insert, esh-io-test/redirect-copy)
(esh-io-test/redirect-copy-first, esh-io-test/redirect-pipe): New
tests.
* doc/misc/eshell.texi (Redirection): Document new redirection syntax.
(Pipelines): Document '|&' syntax.
(Bugs and ideas): Update item about redirection syntax.
* etc/NEWS: Announce this change.
Diffstat (limited to 'lisp/eshell/esh-arg.el')
-rw-r--r-- | lisp/eshell/esh-arg.el | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/lisp/eshell/esh-arg.el b/lisp/eshell/esh-arg.el index 50fb7f5fdc6..576d32b8c5d 100644 --- a/lisp/eshell/esh-arg.el +++ b/lisp/eshell/esh-arg.el @@ -29,6 +29,9 @@ (require 'esh-util) +(eval-when-compile + (require 'cl-lib)) + (defgroup eshell-arg nil "Argument parsing involves transforming the arguments passed on the command line into equivalent Lisp forms that, when evaluated, will @@ -248,10 +251,16 @@ convert the result to a number as well." eshell-current-modifiers (cdr eshell-current-modifiers)))) (setq eshell-current-modifiers nil)) -(defun eshell-finish-arg (&optional argument) - "Finish the current ARGUMENT being processed." - (if argument - (setq eshell-current-argument argument)) +(defun eshell-finish-arg (&rest arguments) + "Finish the current argument being processed. +If any ARGUMENTS are specified, they will be added to the final +argument list in place of the value of the current argument." + (when arguments + (if (= (length arguments) 1) + (setq eshell-current-argument (car arguments)) + (cl-assert (and (not eshell-arg-listified) + (not eshell-current-modifiers))) + (setq eshell-current-argument (cons 'eshell-flatten-args arguments)))) (throw 'eshell-arg-done t)) (defun eshell-quote-argument (string) @@ -291,7 +300,11 @@ Point is left at the end of the arguments." (if (= (point) here) (error "Failed to parse argument `%s'" (buffer-substring here (point-max)))) - (and arg (nconc args (list arg))))))) + (when arg + (nconc args + (if (eq (car-safe arg) 'eshell-flatten-args) + (cdr arg) + (list arg)))))))) (throw 'eshell-incomplete (if (listp delim) delim (list delim (point) (cdr args))))) |