[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: |
Eli Zaretskii |
Subject: |
bug#59960: 30.0.50; Eshell's $* variable (used to define aliases) doesn't work as expected |
Date: |
Sun, 11 Dec 2022 10:04:22 +0200 |
> Date: Sat, 10 Dec 2022 22:13:39 -0800
> From: Jim Porter <jporterbugs@gmail.com>
>
> 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.
AFAICT, the fact that $* produces a sub-list is not mentioned in the
documentation part of the patch. I think it should, if only to
explain why a special expansion is needed.