unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: larsi@gnus.org, 57129@debbugs.gnu.org
Subject: bug#57129: 29.0.50; Improve behavior of conditionals in Eshell
Date: Sat, 13 Aug 2022 22:37:12 -0700	[thread overview]
Message-ID: <9ca08054-5b73-a13e-0478-d838b650317b@gmail.com> (raw)
In-Reply-To: <83pmh3l8ey.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 3225 bytes --]

On 8/13/2022 10:07 PM, Eli Zaretskii wrote:
>> Cc: larsi@gnus.org, 57129@debbugs.gnu.org
>> From: Jim Porter <jporterbugs@gmail.com>
>> Date: Sat, 13 Aug 2022 11:56:20 -0700
>>
>> Sorry about that. I think that's the right fix for that case. Maybe it
>> would make sense to set 'eshell-prefer-lisp-functions' to t for most of
>> the Eshell tests to improve reproducibility on various platforms; tests
>> that want an external command can just put a "*" in front of the command
>> name.
> 
> 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.

>> I'm surprised that test fails on MS Windows, since it *should* be
>> testing internal Eshell logic that's not platform-specific. Based on the
>> failure, it looks like one of the following commands is returning the
>> wrong value:
>>
>>     echo {echo $eshell-in-pipeline-p | echo} | *cat
>>     echo ${echo $eshell-in-pipeline-p | echo} | *cat
>>     *cat $<echo $eshell-in-pipeline-p | echo> | *cat
>>
>> All of these should return 'first'.
> 
> The first two do; the last one returns nothing.
[snip]
> So how to investigate this failure further?

I have access to an MS Windows system (but don't have a build 
environment set up for native MS Windows builds), so I can try to 
reproduce this using the Emacs 29 pretest binaries in the next few days. 
Hopefully that works.

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. 
The two functions that set 'eshell-in-pipeline-p' in there are:

* 'eshell-as-subcommand', which resets it to nil so that the outer
   command's pipeline state doesn't interfere with the subcommand.

* 'eshell-execute-pipeline', which calls 'eshell-do-pipelines' (except
   on MS-DOS, I think) and should set 'eshell-in-pipeline-p' to 'first'
   in the above case.

>> If nothing else, it would probably be helpful to set up ERT explainers
>> so that the error messages are easier to understand. As it is now,
>> they're not very explanatory.
> 
> Indeed, more explanations in this and other tests will be most
> welcome.

Yeah, this test in particular is high up on the list of tests that needs 
more explanation. It's pretty subtle, and the test doesn't really serve 
as a good example of why someone would care that this behavior works the 
way the test demands it.

[-- Attachment #2: parsed-command.el --]
[-- Type: text/plain, Size: 1563 bytes --]

(eshell-trap-errors
 (eshell-execute-pipeline
  '((eshell-named-command
     (eshell-concat nil "*" "cat")
     (list
      (eshell-escape-arg
       (let
           ((indices
             (eshell-eval-indices 'nil)))
         (let
             ((eshell-current-handles
               (eshell-create-handles "/tmp/QqPFwo" 'overwrite)))
           (progn
             (eshell-as-subcommand
              (eshell-trap-errors
               (eshell-execute-pipeline
                '((eshell-named-command "echo"
                                        (list
                                         (eshell-escape-arg
                                          (let
                                              ((indices
                                                (eshell-eval-indices 'nil)))
                                            (eshell-get-variable
                                             #("eshell-in-pipeline-p" 0 20
                                               (escaped t))
                                             indices nil)))))
                  (progn
                    (ignore
                     (eshell-set-output-handle 1 'overwrite "/tmp/QqPFwo"))
                    (eshell-named-command "echo"))))))
             (ignore
              (nconc eshell-this-command-hook
                     (list
                      #'(lambda nil
                          (delete-file "/tmp/QqPFwo")))))
             (eshell-apply-indices "/tmp/QqPFwo" indices nil)))))))
    (eshell-named-command
     (eshell-concat nil "*" "cat")))))

  reply	other threads:[~2022-08-14  5:37 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-11  2:43 bug#57129: 29.0.50; Improve behavior of conditionals in Eshell Jim Porter
2022-08-11  2:46 ` Jim Porter
2022-08-12 15:22   ` Lars Ingebrigtsen
2022-08-13  5:14     ` Jim Porter
2022-08-13  7:01       ` Eli Zaretskii
2022-08-13 18:56         ` Jim Porter
2022-08-14  5:07           ` Eli Zaretskii
2022-08-14  5:37             ` Jim Porter [this message]
2022-08-14  7:30               ` Eli Zaretskii
2022-08-14 21:40                 ` Jim Porter
2022-08-15 12:13                   ` Eli Zaretskii
2022-08-15 16:14                     ` Jim Porter
2022-08-15 16:49                       ` Eli Zaretskii
2022-08-15 18:08                         ` Jim Porter
2022-08-15 18:21                           ` Eli Zaretskii
2022-08-15 18:30                             ` Jim Porter
2022-08-15 18:58                               ` Eli Zaretskii
2022-08-15 20:55                                 ` Paul Eggert
     [not found]                                 ` <af0af29b-2362-77db-081e-046158937808@cs.ucla.edu>
2022-08-15 21:22                                   ` Bruno Haible
2022-08-16 11:04                                   ` Eli Zaretskii
     [not found]                                   ` <835yish2l1.fsf@gnu.org>
2022-08-16 13:35                                     ` Bruno Haible
     [not found]                                     ` <1871347.6tgchFWduM@nimes>
2022-08-16 13:51                                       ` Eli Zaretskii
     [not found]                                       ` <838rnofgad.fsf@gnu.org>
2022-08-16 14:40                                         ` Bruno Haible
2022-08-16 16:25                                           ` Eli Zaretskii
     [not found]                                           ` <83wnb8dukz.fsf@gnu.org>
2022-08-16 16:54                                             ` Paul Eggert
     [not found]                                             ` <206e38df-2db4-a46a-e0ff-952bc8ab939c@cs.ucla.edu>
2022-08-16 17:04                                               ` Eli Zaretskii
     [not found]                                               ` <83sflwdsr2.fsf@gnu.org>
2022-08-16 17:30                                                 ` Paul Eggert
2022-08-16 17:41                                                 ` Eli Zaretskii
     [not found]                                                 ` <ceeeaa86-6199-93b1-ff65-bbd3e531e235@cs.ucla.edu>
2022-08-16 17:56                                                   ` Eli Zaretskii
2022-08-16 17:25                                             ` Paul Eggert
2022-08-16 17:29                                             ` Bruno Haible
     [not found]                                             ` <f329244a-cba7-65cd-2e5d-2630eba3e9e9@cs.ucla.edu>
2022-08-16 17:47                                               ` Eli Zaretskii
2022-08-16 19:11                                                 ` Paul Eggert
     [not found]                                                 ` <d95734ab-6bbc-7403-c1f8-fbf742badda4@cs.ucla.edu>
2022-08-16 20:12                                                   ` Bruno Haible
2022-08-17 11:08                                                   ` Eli Zaretskii
     [not found]                                                   ` <83h72bdt4z.fsf@gnu.org>
2022-08-18  6:05                                                     ` Paul Eggert
     [not found]                                                     ` <57b8f10f-8e9b-5951-e5ad-8cba2a8cb569@cs.ucla.edu>
2022-08-18  6:44                                                       ` Eli Zaretskii
     [not found]                                             ` <2594092.Isy0gbHreE@nimes>
2022-08-16 17:52                                               ` Eli Zaretskii
2022-08-16 20:06                                                 ` Bruno Haible
     [not found]                                                 ` <2606289.q0ZmV6gNhb@nimes>
2022-08-17 11:29                                                   ` Eli Zaretskii
2022-08-16 19:59                                         ` Bruno Haible
     [not found]                                         ` <2135151.C4sosBPzcN@nimes>
2022-08-16 20:53                                           ` Paul Eggert
2022-08-21 16:20                                             ` Bruno Haible
2022-08-21 16:32                                               ` Eli Zaretskii
2022-08-21 17:17                                               ` Bruno Haible
2022-08-22 20:47                                                 ` Paul Eggert
     [not found]                                                 ` <2dc7ede0-eca7-baf5-f89a-f5d292b80808@cs.ucla.edu>
2022-08-23  0:13                                                   ` Bruno Haible
     [not found]                                                   ` <3893771.2iPT33SAM4@nimes>
2022-08-23 11:18                                                     ` Eli Zaretskii
     [not found]                                                     ` <831qt79pjj.fsf@gnu.org>
2022-08-23 14:49                                                       ` Bruno Haible
2022-08-23 16:07                                                         ` Eli Zaretskii
2022-08-20 18:03                                 ` Jim Porter
2022-08-20 18:14                                   ` Eli Zaretskii
2022-08-20 18:49                                     ` Jim Porter
2022-08-24 21:41                                   ` Jim Porter
2022-08-26  5:10                                     ` Jim Porter
2023-03-16  5:35                                       ` Jim Porter
2022-08-14  5:03       ` Sean Whitton

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=9ca08054-5b73-a13e-0478-d838b650317b@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=57129@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=larsi@gnus.org \
    /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).