bug-make
[Top][All Lists]
Advanced

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

RE: not a bug but some strange behaviour


From: Martin Dorey
Subject: RE: not a bug but some strange behaviour
Date: Tue, 1 Dec 2009 14:32:34 -0800

> 1) if bash as no config files it seems that it strip the env

> 2) if make don't find the SHELL it don't complain and run it using

> cmd? bash? (in case of cygwin) and then strip the env

 

Occam's Razor suggests that it's unlikely that two programs are both stripping your environment.

 

> if make don't find the SHELL it don't complain

 

Test case demonstrating that?  Here's my counter-example:

 

$ ./make.bat test3

 

C:\Documents and Settings\martind\playpen\jlm-2009-11-30>set PATH=C:\cygwin-1.5\bin;C:\cygwin-1.5\usr\local\bin;C:\cygwin-1.5\bin;C:\cygwin-1.5\bin;C:\cygwin-1.5\usr\X11R6\bin;c:\WINDOWS\system32;c:\WINDOWS;c:\WINDOWS\System32\Wbem;c:\wix;c:\Program Files\software.jessies.org\evergreen\Resources\evergreen\bin\;c:\Program Files\software.jessies.org\scm\Resources\scm\bin\;c:\Program Files\software.jessies.org\terminator\Resources\terminator\bin\

 

C:\Documents and Settings\martind\playpen\jlm-2009-11-30>c:\cygwin-1.5\bin\make test3

printf "${ENV_VAR1}\n"

make: clunk: Command not found

make: *** [test3] Error 127

$ cat Makefile

 

export TEST_FLAG=test

SHELL=clunk

 

test :

        printf "$${TEST_FLAG}\n"

 

test2 :

        printf "${TEST_FLAG}\n"

 

test3 :

        printf "$${ENV_VAR1}\n"

 

test4 :

        printf "${ENV_VAR1}\n"

 

test5 :

        ENV_VAR1=${ENV_VAR1}; /bin/bash somescriptthatdoprintfenv_var1

 

 

$

 

make contains an optimization whereby it will invoke simple commands directly rather than going via SHELL, if it thinks SHELL is a "unixy" shell and if the command looks simple enough that it thinks it can do this without affecting the semantics of the command.  I bet that's involved somehow, but the code is really quite complicated.  Assigning to SHELL (why?) certainly can affect it.  Observing its behavior in practice is convoluted by a similar optimization in modern bash, which exec()s the last command it will perform, rather than fork()ing and waitpid()ing.

 

-----Original Message-----
From: jean-luc malet [mailto:address@hidden
Sent: Tuesday, December 01, 2009 06:37
To: Martin Dorey
Cc: bug-make
Subject: Re: not a bug but some strange behaviour

 

well I'm replying to myself ;)

 

so there was a combinaison of several issues

 

1) if bash as no config files it seems that it strip the env

2) if make don't find the SHELL it don't complain and run it using

cmd? bash? (in case of cygwin) and then strip the env

 

so the fixes was :

run all shell wrapper through sh

put SHELL = sh

 

now it seems to work fine... result in 4h of build...

thanks for the support

JLM

 

On Tue, Dec 1, 2009 at 2:53 PM, jean-luc malet <address@hidden> wrote:

> almost....

> it seems that it fixe the shell script but if I call some dos tool

> inside, then the env is striped again....

> some other points :

> 

> if I wrap the cmd into a shell all is working :

> sh$ tail -F /tmp/cmd.file | cmd > /tmp/log.file &

> sh$ echo cd the\\path\\to\\the\\make.bat\\ >> /tmp/cmd.file

> sh$ echo make.bat test >> /tmp/cmd.file

> sh$ cat /tmp/cmd.file; #all is ok

> 

> so it seems really related to the fact that make behave differently if

> launched in a cmd or if somewhere else before a cygwin session as been

> created....

> 

> On Tue, Dec 1, 2009 at 11:44 AM, jean-luc malet <address@hidden> wrote:

>> found!

>> I was using SHELL = /bin/sh

>> I shall have used SHELL = sh

>> and in fact make behave differently if the path is inside the SHELL variable....

>> info make in section choosing the shell....

>> however I find this strange and confusing that make behave differently

>> on dos/windows than on cygwin/unix....

>> JLM

>> 

>> On Tue, Dec 1, 2009 at 11:05 AM, jean-luc malet <address@hidden> wrote:

>>> in the bat file you have to do

>>> call path\to\the\real\make.exe %*

>>> you might also want to use the -f option of make to have it using the

>>> right makefile

>>> JLM

>>> 

>>> On Mon, Nov 30, 2009 at 11:58 PM, Martin Dorey <address@hidden> wrote:

>>>>> $make.bat test3

>>>> 

>>>>> <empty line>

>>>> 

>>>> 

>>>> 

>>>> Interestingly, I failed to reproduce your problem:

>>>> 

>>>> 

>>>> 

>>>> $ ./make.bat test3

>>>> 

>>>> 

>>>> 

>>>> C:\Documents and

>>>> Settings\martind\playpen\jlm-2009-11-30>C:\cygwin-1.5\bin\make test3

>>>> 

>>>> printf "${ENV_VAR1}\n"

>>>> 

>>>> fromtheenv

>>>> 

>>>> $

>>>> 

>>>> 

>>>> 

>>>> I tried with Cygwin 1.5 and 1.7.  Here's more information about the 1.5

>>>> versions:

>>>> 

>>>> 

>>>> 

>>>> $ uname -a

>>>> 

>>>> CYGWIN_NT-5.1 vm-martind 1.5.25(0.156/4/2) 2008-06-12 19:34 i686 Cygwin

>>>> 

>>>> $ bash --version

>>>> 

>>>> GNU bash, version 3.2.49(22)-release (i686-pc-cygwin)

>>>> 

>>>> Copyright (C) 2007 Free Software Foundation, Inc.

>>>> 

>>>> $ make --version

>>>> 

>>>> GNU Make 3.81

>>>> 

>>>> Copyright (C) 2006  Free Software Foundation, Inc.

>>>> 

>>>> This is free software; see the source for copying conditions.

>>>> 

>>>> There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A

>>>> 

>>>> PARTICULAR PURPOSE.

>>>> 

>>>> 

>>>> 

>>>> This program built for i686-pc-cygwin

>>>> 

>>>> $

>>>> 

>>>> 

>>>> 

>>>> The exact test case I used wasn't quite the same as you gave:

>>>> 

>>>> 

>>>> 

>>>> $ cat make.bat

>>>> 

>>>> C:\cygwin-1.5\bin\make %*

>>>> 

>>>> $ cat Makefile

>>>> 

>>>> 

>>>> 

>>>> export TEST_FLAG=test

>>>> 

>>>> SHELL=/bin/bash

>>>> 

>>>> 

>>>> 

>>>> test :

>>>> 

>>>>         printf "$${TEST_FLAG}\n"

>>>> 

>>>> 

>>>> 

>>>> test2 :

>>>> 

>>>>         printf "${TEST_FLAG}\n"

>>>> 

>>>> 

>>>> 

>>>> test3 :

>>>> 

>>>>         printf "$${ENV_VAR1}\n"

>>>> 

>>>> 

>>>> 

>>>> test4 :

>>>> 

>>>>         printf "${ENV_VAR1}\n"

>>>> 

>>>> 

>>>> 

>>>> test5 :

>>>> 

>>>>         ENV_VAR1=${ENV_VAR1}; /bin/bash somescriptthatdoprintfenv_var1

>>>> 

>>>> 

>>>> 

>>>> 

>>>> 

>>>> $

>>>> 

>>>> 

>>>> 

>>>> If I had make.bat run "make", then it ended up invoking itself.  My bat-fu

>>>> is weak:

>>>> 

>>>> 

>>>> 

>>>> $ cat make.bat

>>>> 

>>>> set PATH=C:\cygwin-1.5\bin;%PATH%

>>>> 

>>>> make %*

>>>> 

>>>> $

>>>> 

>>>> 

>>>> 

>>>> -----Original Message-----

>>>> From: jean-luc malet [mailto:address@hidden

>>>> Sent: Monday, November 30, 2009 14:27

>>>> To: Martin Dorey

>>>> Cc: bug-make

>>>> Subject: Re: not a bug but some strange behaviour

>>>> 

>>>> 

>>>> 

>>>> $cat make.bat

>>>> 

>>>> set PATH=cygwin_Path;oldPath

>>>> 

>>>> make %*

>>>> 

>>>> 

>>>> 

>>>> $ cat /tmp/Makefile

>>>> 

>>>> 

>>>> 

>>>> export TEST_FLAG=test

>>>> 

>>>> SHELL=/bin/bash

>>>> 

>>>> 

>>>> 

>>>> test :

>>>> 

>>>> <tab> printf "$${TEST_FLAG}\n"

>>>> 

>>>> 

>>>> 

>>>> test2 :

>>>> 

>>>> <tab> printf "${TEST_FLAG}\n"

>>>> 

>>>> 

>>>> 

>>>> test3 :

>>>> 

>>>> <tab> printf "$${ENV_VAR1}\n"

>>>> 

>>>> 

>>>> 

>>>> test4 :

>>>> 

>>>> <tab> printf "${ENV_VAR1}\n"

>>>> 

>>>> 

>>>> 

>>>> test5 :

>>>> 

>>>> <tab> ENV_VAR1=${ENV_VAR1}; /bin/bash somescriptthatdoprintfenv_var1

>>>> 

>>>> 

>>>> 

>>>> 

>>>> 

>>>> 

>>>> 

>>>> $ export ENV_VAR1=fromtheenv

>>>> 

>>>> ----- cygwin env (make is called throught a .bat file) -----

>>>> 

>>>> $ make.bat test

>>>> 

>>>> <empty line>

>>>> 

>>>> $ make.bat test2

>>>> 

>>>> test

>>>> 

>>>> $make.bat test3

>>>> 

>>>> <empty line>

>>>> 

>>>> $make.bat test4

>>>> 

>>>> fromtheenv

>>>> 

>>>> $make.bat test5

>>>> 

>>>> fromtheenv

>>>> 

>>>> 

>>>> 

>>>> ------ from an interactive shell, cygwin env ----

>>>> 

>>>> $make test

>>>> 

>>>> test

>>>> 

>>>> $make test2

>>>> 

>>>> test

>>>> 

>>>> $make test3

>>>> 

>>>> fromtheenv

>>>> 

>>>> $make test4

>>>> 

>>>> fromtheenv

>>>> 

>>>> $make test5

>>>> 

>>>> fromtheenv

>>>> 

>>>> 

>>>> 

>>>> ------- linux ------

>>>> 

>>>> always working

>>>> 

>>>> 

>>>> 

>>>> to make it short : if you call the subshell by setting the env

>>>> 

>>>> variable on the same line it will ever work

>>>> 

>>>> if you try to access some env variable in the makefile it always work

>>>> 

>>>> if you try to use the env variable into one of the command it fails

>>>> 

>>>> depending on the context.....

>>>> 

>>>> 

>>>> 

>>>> Best Regards

>>>> 

>>>> JLM

>>>> 

>>>> 

>>>> 

>>>> On Mon, Nov 30, 2009 at 8:22 PM, Martin Dorey <address@hidden> wrote:

>>>> 

>>>>> Can you contrive a simple test case - something that you can post here in

>>>>> its entirety to help someone reproduce the problem?

>>>> 

>>>>> 

>>>> 

>>>>> -----Original Message-----

>>>> 

>>>>> From: address@hidden

>>>>> [mailto:address@hidden On Behalf Of jean-luc

>>>>> malet

>>>> 

>>>>> Sent: Monday, November 30, 2009 10:27

>>>> 

>>>>> To: bug-make

>>>> 

>>>>> Subject: not a bug but some strange behaviour

>>>> 

>>>>> 

>>>> 

>>>>> Hi!

>>>> 

>>>>> I have a cygwin environment in which I've written a makefile, in this

>>>> 

>>>>> environment it's working fine

>>>> 

>>>>> I want to make it available to other dos user, so I've written a bat

>>>> 

>>>>> file that set the cygwin path and call make,

>>>> 

>>>>> in the doc env when I do

>>>> 

>>>>> echo %somevar%

>>>> 

>>>>> I see the correct result

>>>> 

>>>>> however in commands launched by make (shell scripts) the ${somevar}

>>>> 

>>>>> expand to nothing... as if make was stripping the env....

>>>> 

>>>>> any idea?

>>>> 

>>>>> thanks

>>>> 

>>>>> JLM

>>>> 

>>>>> 

>>>> 

>>>>> --

>>>> 

>>>>> KISS! (Keep It Simple, Stupid!)

>>>> 

>>>>> (garde le simple, imbécile!)

>>>> 

>>>>> "mais qu'est-ce que tu m'as pondu comme usine à gaz? fait des choses

>>>> 

>>>>> simples et qui marchent, espèce d'imbécile!"

>>>> 

>>>>> -----------------------------

>>>> 

>>>>> "Si vous pensez que vous êtes trop petit pour changer quoique ce soit,

>>>> 

>>>>> essayez donc de dormir avec un moustique dans votre chambre." Betty

>>>> 

>>>>> Reese

>>>> 

>>>>> http://www.grainesdechangement.com/citations.htm

>>>> 

>>>>> 

>>>> 

>>>>> 

>>>> 

>>>>> _______________________________________________

>>>> 

>>>>> Bug-make mailing list

>>>> 

>>>>> address@hidden

>>>> 

>>>>> http://lists.gnu.org/mailman/listinfo/bug-make

>>>> 

>>>>> 

>>>> 

>>>> 

>>>> 

>>>> 

>>>> 

>>>> 

>>>> 

>>>> --

>>>> 

>>>> KISS! (Keep It Simple, Stupid!)

>>>> 

>>>> (garde le simple, imbécile!)

>>>> 

>>>> "mais qu'est-ce que tu m'as pondu comme usine à gaz? fait des choses

>>>> 

>>>> simples et qui marchent, espèce d'imbécile!"

>>>> 

>>>> -----------------------------

>>>> 

>>>> "Si vous pensez que vous êtes trop petit pour changer quoique ce soit,

>>>> 

>>>> essayez donc de dormir avec un moustique dans votre chambre." Betty

>>>> 

>>>> Reese

>>>> 

>>>> http://www.grainesdechangement.com/citations.htm

>>> 

>>> 

>>> 

>>> --

>>> KISS! (Keep It Simple, Stupid!)

>>> (garde le simple, imbécile!)

>>> "mais qu'est-ce que tu m'as pondu comme usine à gaz? fait des choses

>>> simples et qui marchent, espèce d'imbécile!"

>>> -----------------------------

>>> "Si vous pensez que vous êtes trop petit pour changer quoique ce soit,

>>> essayez donc de dormir avec un moustique dans votre chambre." Betty

>>> Reese

>>> http://www.grainesdechangement.com/citations.htm

>>> 

>> 

>> 

>> 

>> --

>> KISS! (Keep It Simple, Stupid!)

>> (garde le simple, imbécile!)

>> "mais qu'est-ce que tu m'as pondu comme usine à gaz? fait des choses

>> simples et qui marchent, espèce d'imbécile!"

>> -----------------------------

>> "Si vous pensez que vous êtes trop petit pour changer quoique ce soit,

>> essayez donc de dormir avec un moustique dans votre chambre." Betty

>> Reese

>> http://www.grainesdechangement.com/citations.htm

>> 

> 

> 

> 

> --

> KISS! (Keep It Simple, Stupid!)

> (garde le simple, imbécile!)

> "mais qu'est-ce que tu m'as pondu comme usine à gaz? fait des choses

> simples et qui marchent, espèce d'imbécile!"

> -----------------------------

> "Si vous pensez que vous êtes trop petit pour changer quoique ce soit,

> essayez donc de dormir avec un moustique dans votre chambre." Betty

> Reese

> http://www.grainesdechangement.com/citations.htm

> 

 

 

 

--

KISS! (Keep It Simple, Stupid!)

(garde le simple, imbécile!)

"mais qu'est-ce que tu m'as pondu comme usine à gaz? fait des choses

simples et qui marchent, espèce d'imbécile!"

-----------------------------

"Si vous pensez que vous êtes trop petit pour changer quoique ce soit,

essayez donc de dormir avec un moustique dans votre chambre." Betty

Reese

http://www.grainesdechangement.com/citations.htm


reply via email to

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