How to choose the shell?

John Freeman <[email protected]> Sat, 4 Sep 2021 10:11:19 -0500
Newsgroups gmane.comp.gnu.make.windows
Message-ID <CANm+4TVJcW_=WN7Q8jeWdeCY2hFtJjXrCFj3uW-vsCRMDbnJNg@mail.gmail.com>
--000000000000a0527f05cb2cd48c
Content-Type: text/plain; charset="UTF-8"

I previously sent this message to Eli Zaretskii, whose [EZWinPorts](
https://sourceforge.net/projects/ezwinports/files/) binary I am using. He
asked me to move this conversation here.

I'm trying to choose the shell for my Makefile recipes when I run
EZWinPorts's Windows port of Make 4.3 (without Guile, [installed by Scoop](
https://github.com/ScoopInstaller/Main/blob/master/bucket/make.json)), but
can't seem to get it to work.

For example, I'm running on Windows with PowerShell installed and on the
`PATH`. If I make a target whose recipe is just "`ls`", I get this error:

    process_begin: CreateProcess(NULL, ls, ...) failed.
    make (e=2): The system cannot find the file specified.
    make: *** [Makefile:4: ls] Error 2

That's fine. Maybe it's using `cmd` as the shell for that line (but it
really looks like it ignores all shells and directly calls Windows's
equivalent of `popen`). Then I run through the different [options](
https://www.gnu.org/software/make/manual/html_node/Choosing-the-Shell.html)
for choosing the shell as laid out in the docs.

- I can see that `ComSpec` is set in my default environment. In PowerShell,
I can read it as `$env:ComSpec` or `$env:COMSPEC`, but in a Makefile, it is
only available as `${ComSpec}`. If I remove and re-add the variable under
the name `$env:COMSPEC`, it becomes available in the Makefile as
`${COMSPEC}`, but I still get the same error from the `ls` recipe.
- The default value of `SHELL` in the Makefile is `sh.exe`. If I set
`SHELL` in the Makefile to either `powershell` or the full path to
`powershell.exe`, I get the same error.

How can I achieve my goal? Is this a bug? Is the documentation for a
different version of Make, or out-of-date?

Thank you,
John

--000000000000a0527f05cb2cd48c
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I previously sent this message to Eli Zaretskii, whos=
e [EZWinPorts](<a href=3D"https://sourceforge.net/projects/ezwinports/files=
/">https://sourceforge.net/projects/ezwinports/files/</a>) binary I am usin=
g. He asked me to move this conversation here.</div><div><br></div><div>I&#=
39;m trying to choose the shell for my Makefile recipes when I run EZWinPor=
ts&#39;s Windows port of Make 4.3 (without Guile, [installed by Scoop](<a h=
ref=3D"https://github.com/ScoopInstaller/Main/blob/master/bucket/make.json)=
">https://github.com/ScoopInstaller/Main/blob/master/bucket/make.json)</a>)=
, but can&#39;t seem to get it to work.<br><br>For example, I&#39;m running=
 on Windows with PowerShell installed and on the `PATH`. If I make a target=
 whose recipe is just &quot;`ls`&quot;, I get this error:<br><br>=C2=A0 =C2=
=A0 process_begin: CreateProcess(NULL, ls, ...) failed.<br>=C2=A0 =C2=A0 ma=
ke (e=3D2): The system cannot find the file specified.<br>=C2=A0 =C2=A0 mak=
e: *** [Makefile:4: ls] Error 2<br><br>That&#39;s fine. Maybe it&#39;s usin=
g `cmd` as the shell for that line (but it really looks like it ignores all=
 shells and directly calls Windows&#39;s equivalent of `popen`). Then I run=
 through the different [options](<a href=3D"https://www.gnu.org/software/ma=
ke/manual/html_node/Choosing-the-Shell.html">https://www.gnu.org/software/m=
ake/manual/html_node/Choosing-the-Shell.html</a>) for choosing the shell as=
 laid out in the docs.<br><br>- I can see that `ComSpec` is set in my defau=
lt environment. In PowerShell, I can read it as `$env:ComSpec` or `$env:COM=
SPEC`, but in a Makefile, it is only available as `${ComSpec}`. If I remove=
 and re-add the variable under the name `$env:COMSPEC`, it becomes availabl=
e in the Makefile as `${COMSPEC}`, but I still get the same error from the =
`ls` recipe.<br>- The default value of `SHELL` in the Makefile is `sh.exe`.=
 If I set `SHELL` in the Makefile to either `powershell` or the full path t=
o `powershell.exe`, I get the same error.</div><div><br></div><div>How can =
I achieve my goal? Is this a bug? Is the documentation for a different vers=
ion of Make, or out-of-date?</div><div><br></div><div>Thank you,</div><div>=
John<br></div></div>

--000000000000a0527f05cb2cd48c--