emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#59960: closed (30.0.50; Eshell's $* variable (used to define aliases


From: GNU bug Tracking System
Subject: bug#59960: closed (30.0.50; Eshell's $* variable (used to define aliases) doesn't work as expected)
Date: Fri, 16 Dec 2022 06:11:02 +0000

Your message dated Thu, 15 Dec 2022 22:10:50 -0800
with message-id <a5861773-c78c-68ee-5475-74c7a66d0091@gmail.com>
and subject line Re: bug#59960: 30.0.50; Eshell's $* variable (used to define 
aliases) doesn't work as expected
has caused the debbugs.gnu.org bug report #59960,
regarding 30.0.50; Eshell's $* variable (used to define aliases) doesn't work 
as expected
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
59960: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59960
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: 30.0.50; Eshell's $* variable (used to define aliases) doesn't work as expected Date: Sat, 10 Dec 2022 22:13:39 -0800 This bug report originally comes from a Reddit post[1] where a user found that aliasing the Eshell built-in "mv" and "cp" commands didn't work properly. I'll show a slightly simpler example though. Starting from "emacs -Q -f eshell":

  ~ $ alias my-echo "echo A $* Z"
  ~ $ my-echo b c d
  ("A"
   ("b" "c" "d")
   "Z")

  ~ $ echo A b c d Z
  ("A" "b" "c" "d" "Z")

As you can see above, the "$*" special variable inserts the list of arguments passed to the alias *as a sublist*. That might be what you want sometimes, but more likely, you'd want to insert the arguments in-place, like with ",@" in Emacs Lisp backquote forms. (Note: for external processes, this isn't an issue because Eshell flattens all the arguments to external commands.)

Attached is a draft patch to fix this. It adds a new "$@expr" variable expansion to Eshell which lets you splice a list in-place:

  ~ $ alias my-echo 'echo A $@* Z'
  ~ $ my-echo b c d
  ("A" "b" "c" "d" "Z")

Currently, this only works in simple situations like the above. It should work for any variable, but likely won't work with Eshell for loops, inside double quotes, etc. It would be nice to get this working in a wider variety of places in Eshell command forms before merging. Still, even what's here is already pretty useful, I think. I'm posting this now mainly to get feedback on whether this is the right direction to go in the first place.

[1] https://old.reddit.com/r/emacs/comments/xs2ofo/eshell_aliases_for_mv_and_cp_using_their_elisp/

Attachment: 0001-Support-completion-of-variables-with-the-length-oper.patch
Description: Text document

Attachment: 0002-Add-support-for-the-splice-operator-in-Eshell.patch
Description: Text document


--- End Message ---
--- Begin Message --- Subject: Re: bug#59960: 30.0.50; Eshell's $* variable (used to define aliases) doesn't work as expected Date: Thu, 15 Dec 2022 22:10:50 -0800
On 12/12/2022 5:04 PM, Jim Porter wrote:
Thanks. I'll leave this open for a bit in case anyone else has comments on the code (and I'll keep testing locally to see if there are any obvious bugs). If no one has any issues, I'll merge this in a few days.

Merged as b8eef7b8c1066cf446ca1b37d3fd5c1ea3e3ab07. Closing this bug now. Thanks again.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]