[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#59960: 30.0.50; Eshell's $* variable (used to define aliases) doesn'
From: |
Jim Porter |
Subject: |
bug#59960: 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/
0001-Support-completion-of-variables-with-the-length-oper.patch
Description: Text document
0002-Add-support-for-the-splice-operator-in-Eshell.patch
Description: Text document
- bug#59960: 30.0.50; Eshell's $* variable (used to define aliases) doesn't work as expected,
Jim Porter <=