Subject: Re: bug#25270: eshell -- programmatically send input -- feature request

From: Jim Porter <[email-masked]>
Date: Mon, 16 May 2022 10:33:49 -0700

On 5/16/2022 5:13 AM, Lars Ingebrigtsen wrote:
> Jim Porter <[email-masked]> writes:
> 
>> Also, for the code posted in the original message, I'm not sure the
>> changes to `eshell-parse-command' are needed. It should already let
>> you pass a command string to it. Maybe this is because there's an
>> issue with how `eshell-parse-command' temporarily inserts COMMAND into
>> the buffer (see the FIXME comment in the code in the original
>> message)? If there is, we'd probably have to think quite a bit more
>> about how to resolve it.
> 
> Yes, if I understood correctly, that was the main problem -- inserting
> things into the buffer to eval it sometimes leaves artefacts (or doesn't
> work), so it'd be better to talk directly to the underlying shell to get
> things evalled.

I think for talking to Eshell itself, inserting things into the buffer 
(temporarily) should be ok. Eshell already does this (as of Emacs 29, I 
think) when parsing some complex commands. If you have some $-expansions 
inside double-quotes, e.g. 'echo "${echo \"hi there\"}"', Eshell 
temporarily inserts 'echo "hi there"' into the buffer to parse it, and 
then removes it before proceeding.

For sending input to a child process being run inside Eshell, we 
wouldn't do all this, since Eshell wouldn't be treating the input as an 
Eshell command to be parsed. In that case, we could just send the string 
to the child process directly (possibly with some extra Eshell bookkeeping).