Subject: Re: bug#36270: executable-find does not find shell commands on MSYS2

From: Eli Zaretskii <[email-masked]>
Date: Tue, 18 Jun 2019 19:51:42 +0300

> From: Juanma Barranquero <[email-masked]>
> Date: Tue, 18 Jun 2019 02:57:59 +0200
> Cc: [email-masked]
> 
> Still, there's nothing magic about call-process. Is the native way,
> but not the only way to execute programs on Emacs. Why should
> file-executable-p and executable-find privilege native vs shell
> commands, in contexts where you can run the shell command easily?

Because otherwise we would have inconsistencies: executable-find will
find an "executable" which Emacs may or may not be able to run.  We
want to declare a file "executable" only if it can be invoked by _all_
possible means of running an executable file.

This is a Windows-specific subtlety, because the mechanism for running
arbitrary scripts is different from that of Posix systems.  We could
make the situation a tad better if we add support for the PATHEXT
environment variable, as suggested in bug#7784, patches welcome.  But
this won't solve the problem entirely, when the user has some
interpreter installed which doesn't register itself in PATHEXT.

> (let ((shell-file-name "bash"))
>   (shell-command "ci --version"))
> 
> => 0
> 
> As I said above, there's tension between two meanings of "executable"
> here. Both are meaningful.

I might be okay with adding a new function, shell-executable-find,
say.  But we must first define what that means, exactly, and whether
it's feasible to implement something like that with reasonable effort
and complexity.

Meanwhile, just set up trivial batch file wrappers for your shell
scripts, and Bob's your uncle.