unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Jim Porter <jporterbugs@gmail.com>
Cc: 59960@debbugs.gnu.org
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	[thread overview]
Message-ID: <83fsdmv01l.fsf@gnu.org> (raw)
In-Reply-To: <9d1df9de-5ecc-0499-de5f-28d34f6a821d@gmail.com> (message from Jim Porter on Sat, 10 Dec 2022 22:13:39 -0800)

> 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.





  reply	other threads:[~2022-12-11  8:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-11  6:13 bug#59960: 30.0.50; Eshell's $* variable (used to define aliases) doesn't work as expected Jim Porter
2022-12-11  8:04 ` Eli Zaretskii [this message]
2022-12-12  4:36   ` Jim Porter
2022-12-12  6:49     ` Jim Porter
2022-12-12 12:27     ` Eli Zaretskii
2022-12-13  1:04       ` Jim Porter
2022-12-16  6:10         ` Jim Porter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83fsdmv01l.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=59960@debbugs.gnu.org \
    --cc=jporterbugs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).