Subject: bug#57129: 29.0.50; Improve behavior of conditionals in Eshell

From: Eli Zaretskii <[email-masked]>
Date: Sun, 14 Aug 2022 10:30:02 +0300

> Cc: [email-masked], [email-masked]
> From: Jim Porter <[email-masked]>
> Date: Sat, 13 Aug 2022 22:37:12 -0700
> 
> > But then this fragment from the Eshell manual:
> > 
> >       The command can be either an Elisp function or an external command.
> >    Eshell looks first for an alias (*note Aliases::) with the same name as
> >    the command, then a built-in (*note Built-ins::) or a function with the
> >    same name; if there is no match, it then tries to execute it as an
> >    external command.
> > 
> > seems to be inaccurate?  Since 'format' exists as a built-in command,
> > why did Eshell in this case invoke the external command instead?
> 
> "Built-in" in that part of the manual refers to a function named 
> 'eshell/FOO'. If you run "FOO" as an Eshell command, it will check for 
> 'eshell/FOO' before an external command on your system. The manual could 
> probably stand to be improved here.

The manual definitely should be clarified in that matter, because:

  d:/gnu/git/emacs/trunk/src $ which format
  format is a built-in function in ‘C source code’.

To me this says that 'format' is a built-in command, and the manual
says such commands should be invoked in preference to external
commands.  The "eshell/" part is not mentioned anywhere.

> If you'd like to dig into this further yourself, you could try running 
> this command in Eshell:
> 
>    eshell-parse-command '*cat $<echo $eshell-in-pipeline-p | echo> | *cat'
> 
> That will print the Lisp form that the command gets converted to. I've 
> attached the result that I get in a recent Emacs 29 build on GNU/Linux. 

I get the same output, with 2 exceptions:

  . the name of the temporary file is different
  . instead of a simple string here:

                     (eshell-set-output-handle 1 'overwrite "/tmp/QqPFwo"))

    I get a file name split into several parts, which are then
    concatenated by eshell-concat:

		     (eshell-set-output-handle 1 'overwrite
					       (eshell-extended-glob
						(eshell-concat nil "c:/DOCUME" "~" "1/Zaretzky/LOCALS" "~" "1/Temp/OIi8Wd")))

Any chance that the "~" parts here somehow get in the way?

If not, any other thoughts?  My main worry is that there's something
here specific to how we invoke subprocesses, which you lately changed.