bug-make
[Top][All Lists]
Advanced

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

Build macro not to search for sh.exe or bash.exe


From: David Baird
Subject: Build macro not to search for sh.exe or bash.exe
Date: Thu, 10 Jun 2004 15:06:15 +0300

I wrote:
Please consider a build macro (perhaps NO_UNIXY_SHELL) which will
return(0) from find_and_set_default_shell() in main.c. This will allow
bulding GNU Make on Windows which will not use a sh.exe even if one
exists in the PATH. This is useful for makefiles which use Windows
command lines, and still allows Cygwin, MKS, or other Unixy
installations.

Paul Smith wrote:
Isn't setting the SHELL variable in your makefile sufficient? I'm afraid
I'm not familiar with the gory details of shell selection on Windows
systems. Can you discuss this issue on the <address@hidden> mailing
list to get more specifics? I do read that list.

I respond:
First, I built GNU Make with the NMakefile and Visual C++. No, the SHELL
variable is not helpful to force using cmd.exe instead of sh.exe. Here
is a simple example:

makefile
--------
SHELL = cmd
all:
        for %%i in (a b c) do echo %%i

Run with Cygwin not in Path, no sh.exe found:
C:\Temp>make
for %%i in (a b c) do echo %%i
a
b
c

Run with Cygwin in Path, sh.exe found:
C:\Temp>make
for %%i in (a b c) do echo %%i
C:\DOCUME~1\dbaird\LOCALS~1\Temp\make37242.sh: 1: Syntax error: Bad for
loop variable
make: *** [all] Error 2

Run, forcing SHELL from the command line:
C:\Temp>make SHELL=cmd
for %%i in (a b c) do echo %%i
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Temp>

The second "C:\Temp>" is a prompt for a new cmd.exe shell. The commands
are not run. Typing "exit" leaves the new shell and the make execution.


It seems that setting SHELL in the make file has no effect:

makefile
--------
SHELL = foobar
all:
        for %%i in (a b c) do echo %%i

C:\Temp>make
for %%i in (a b c) do echo %%i
C:\DOCUME~1\dbaird\LOCALS~1\Temp\make34282.sh: 1: Syntax error: Bad for
loop variable
make: *** [all] Error 2

But, setting it on the command line does:
C:\Temp>make SHELL=foobar
for %%i in (a b c) do echo %%i
process_begin: CreateProcess((null), foobar
C:\DOCUME~1\dbaird\LOCALS~1\Temp\make29202.sh, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [all] Error 2


I don't know what the correct action is. If you want to run a command
under cmd.exe, you have to use a -c option:
abc.bat
-------
for %%i in (a b c) do echo %%i

C:\Temp>cmd /c abc.bat

C:\Temp>for %i in (a b c) do echo %i

C:\Temp>echo a
a

C:\Temp>echo b
b

C:\Temp>echo c
c





reply via email to

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