make-w32
[Top][All Lists]
Advanced

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

Re: How to choose the shell?


From: Eli Zaretskii
Subject: Re: How to choose the shell?
Date: Sun, 05 Sep 2021 09:16:07 +0300

> From: John Freeman <jfreeman08@gmail.com>
> Date: Sat, 4 Sep 2021 17:32:05 -0500
> Cc: make-w32@gnu.org
> 
>  It's not documented because the details are complex and hard to
>  explain, and the result isn't supposed to depend on whether Make
>  invokes commands directly or via the shell.  So why do you care to
>  know which way does make invoke a given command?
> 
> Not so complex and hard to explain that you couldn't concisely explain it in 
> this thread and [that thread]
> (https://lists.gnu.org/archive/html/make-w32/2020-05/msg00001.html). Just use 
> one of the two explanations
> you gave. They're totally sufficient, in my opinion.

What I explained is only a part of what's going on.  There are
subtleties with quoting and with what exactly triggers invocation
through shell.  In addition, some of that depends on whether the shell
is sh.exe or cmd.exe.  It's complex, please take my word for it.  That
the simplistic explanation, tailored to your specific use case, was
enough in your case, doesn't yet mean it will satisfy everyone, and
will be accurate enough to be part of the official Make manual.

>  What for?  Make is for building programs by running shell commands.
>  As long as the results of running a command are the same, why should
>  you care how that command is invoked, and why would you need a way to
>  force invocation via the shell?
> 
> You assume that the results are the same. This thread and that thread have 
> demonstrated that they are not.

This part I don't yet understand.  Why invoking 'ls' via PowerShell
works whereas invoking it directly doesn't?  You never explained
that.  So I don't think I have a clear enough understanding of what you
wanted to do and how.

> Makefile that I thought should work according to the documented behavior, and 
> it didn't. _That_ is why I care
> how the commands are invoked. My commands work in the shell, and don't work 
> without the shell. So
> please let me use the shell without having to sign up for the mailing list 
> and jump through an extra hoop on
> every command. A naive implementation would do the right thing every time. 
> This optimization is doing the
> wrong thing some of the time.

If 'ls' in your case is a shell command, then Make doesn't know about
that.  Make on Windows only knows about built-in commands of 2 shells:
sh.exe and cmd.exe, and it applies them according to the current
shell.  So what you wanted to do (AFAIU) wouldn't work on any Posix
system either, and thus it isn't supposed to work on Windows.

My suggestion for running commands that are only known to some
non-standard shell is either write the commands in recipes to invoke
the shell explicitly, or create a batch file, in your case ls.cmd,
which would call PowerShell internally, and put it somewhere on PATH.
Then everything should work without any tricks.

The manual isn't supposed to explain how to trick Make into doing
something it wasn't supposed to do.  Of course, if the GNU Make
maintainers decide to document these internals in the manual, it's
their prerogative.

The above is my opinion; my involvement in GNU Make maintenance is
quite humble.  I CC Paul, the GNU Make maintainer, in case he would
like to comment.



reply via email to

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