Re: exported shell variables and scope
On Thu, 26 Jul 2001, Martijn van Oosterhout wrote:
> On Wed, Jul 25, 2001 at 09:48:36AM -0400, Dale Scheetz wrote:
> > I've had a problem with this issue for a long time now, and have never
> > been able to properly resolve the issue. I am not able to get a broad
> > enough scope to shell defined variables.
> >
> > Simple process: one shell script defines a bunch of variables and the next
> > shell script uses them to perform the work.
>
> When the script exits, all the changes vanish also. To do the change in the
> current shell, you need to "source" the script rather than execute it.
That dawned on me shortly after sending my original posting ;-)
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.
So why aren't the variables exported into the offspring shell in make?
Feeling slow and stupid,
Dwarf
--
_-_-_-_-_- Author of "Dwarf's Guide to Debian GNU/Linux" _-_-_-_-_-_-
_- _-
_- aka Dale Scheetz Phone: 1 (850) 656-9769 _-
_- Flexible Software 11000 McCrackin Road _-
_- e-mail: dwarf@polaris.net Tallahassee, FL 32308 _-
_- _-
_-_-_-_-_- Released under the GNU Free Documentation License _-_-_-_-
available at: http://www.polaris.net/~dwarf/
Reply to: