help-make
[Top][All Lists]
Advanced

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

choice of shell when executing script in recipe, on Windows


From: Russell Kuczwara
Subject: choice of shell when executing script in recipe, on Windows
Date: Thu, 31 Aug 2017 12:26:50 -0400
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

Hey y'all,

I've been debugging an issue with a build system on
Windows, and it looks like my problem is due to how
Make executes a recipe containing a shell script. I'm
wondering if I'm doing something wrong or if this is 
the normal behavior. 

Basically, it looks like Make isn't using the value of
SHELL when the recipe is just a script invocation. Here's
a simple makefile I've been using to test the functionality:

SHELL := C:/SasTools/msys/bin/sh.exe

all: one two

one:
        for NUM in 1 2 3 5; do \
                echo $$NUM; \
        done

two:
        my-script.sh


Its trying to assign SHELL to the sh.exe from an installation
of msys. The SHELL environment variable from the calling 
environment (Windows cmd.exe) is not set, and there is nothing
that looks like sh.exe in the path. 

The execution of 'one' invokes the shell as expected, but the
execution of 'two' has problems:

process_begin: CreateProcess(NULL, sh C:\test\make-sh\my-script.sh, ...) failed.
make (e=2): The system cannot find the file specified.
Makefile:11: recipe for target 'two' failed


Here's the output of the run with the debug flag: 

C:\test\make-sh>make.exe -d --no-builtin-rules
GNU Make 4.1
Built for Windows32
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Reading makefile 'Makefile'...
find_and_set_shell() setting default_shell = C:/SasTools/msys/bin/sh.exe
Updating makefiles....
 Considering target file 'Makefile'.
  Looking for an implicit rule for 'Makefile'.
  No implicit rule found for 'Makefile'.
  Finished prerequisites of target file 'Makefile'.
 No need to remake target 'Makefile'.
Updating goal targets....
Considering target file 'all'.
 File 'all' does not exist.
  Considering target file 'one'.
   File 'one' does not exist.
   Finished prerequisites of target file 'one'.
  Must remake target 'one'.
for NUM in 1 2 3 5; do \
        echo $NUM; \
done
CreateProcess(C:\SasTools\msys\bin\sh.exe,C:/SasTools/msys/bin/sh.exe -c "for 
NUM in 1 2 3 5; do \
        echo $NUM; \
done",...)
Putting child 0222BC30 (one) PID 35842880 on the chain.
Live child 0222BC30 (one) PID 35842880
Main thread handle = 000000EC
1
2
3
5
Reaping winning child 0222BC30 PID 35842880
Removing child 0222BC30 PID 35842880 from chain.
  Successfully remade target file 'one'.
  Considering target file 'two'.
   File 'two' does not exist.
   Finished prerequisites of target file 'two'.
  Must remake target 'two'.
my-script.sh
CreateProcess(NULL,sh C:\test\make-sh\my-script.sh,...)
process_begin: CreateProcess(NULL, sh C:\test\make-sh\my-script.sh, ...) failed.
Putting child 0222BAE0 (two) PID 35841408 on the chain.
Live child 0222BAE0 (two) PID 35841408
make (e=2): The system cannot find the file specified.
Reaping losing child 0222BAE0 PID 35841408
Makefile:12: recipe for target 'two' failed
make.exe: *** [two] Error 2
Removing child 0222BAE0 PID 35841408 from chain.



Any idea why this is occurring? I think I can get around the 
problem by prepending any recipes invoking a script with $(SHELL),
but I'm wondering if there's anything else I can do.

Thanks,

-Russell



reply via email to

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