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

Re: exported shell variables and scope



Make executes each line in its own shell, so the parentheses are needed to
make the "source" happen within the same shell as the call to the mk-pgm
script. In the first case, the setup.sh is being sourced, then that shell's
exited, then a new shell started for the cd and mk-pgm. See the difference
now? :)

On Wed, Jul 25, 2001 at 02:22:25PM -0400, Dale Scheetz <dwarf@polaris.net> spake forth:
> This works fine if I do everything interactively from the prompt, but in a
> makefile, if I do:
> 
> . ./setup.sh
> (cd build ; ./mk-pgm)
> 
> mk-pgm doesn't see the variables. 
> 
> (. ./setup.sh ; cd build ; ./mk-pgm) 
> 
> will work, but I don't understand the difference.
> 
> Yes, the () invokes shell again, but so does ./mk-pgm, and that works fine
> by hand. 

-- 
Mike Markley <mike@markley.org>
GPG: 0x3B047084 7FC7 0DC0 EF31 DF83 7313  FE2B 77A8 F36A 3B04 7084

Our way is peace.
- Septimus, the Son Worshiper, "Bread and Circuses", stardate 4040.7.



Reply to: