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

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

bug#30725: eshell: built-ins do not handle command substitution


From: Jim Porter
Subject: bug#30725: eshell: built-ins do not handle command substitution
Date: Mon, 17 Jan 2022 11:41:47 -0800

On 3/5/2018 8:34 PM, Yegor Timoshenko wrote:
In M-x eshell:

   $ which echo
   eshell/echo is a compiled Lisp function in `em-basic.el'.
   $ which *echo
   /run/current-system/sw/bin/echo
   $ echo ${mktemp -d}
   $ *echo ${mktemp -d}
   /tmp/tmp.UaiWQ0YPIX

I can see this bug with an even simpler case too: "echo ${*echo hi}".

It turns out that this is because `eshell-invoke-directly' thought that the above command was simple enough to, well, invoke directly. However, since "${mktemp -d}" or "${*echo hi}" create a subprocess, the command needs to be invoked *iteratively* by `eshell-eval-command'. The problem was that `eshell-invoke-directly' only checked the top-level command and didn't examine subcommands.

Attached is a patch that fixes this, plus a unit test (I've verified that the test fails without the patch and passes with it). Note that the test *does* rely on the system having an external "echo" command, but I think some of the tests in that file already rely on the presence of an external "sleep" command, so this should be ok. However, if it causes issues on some systems (MS Windows maybe?), just let me know and I can try to put a guard around the test so it doesn't run on such systems.

Attachment: 0001-Consider-subcommands-when-deciding-to-invoke-Eshell-.patch
Description: Text document


reply via email to

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