Re: Export Problem

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

 



On Sat, Aug 28, 2004 at 12:58:41PM -0400, David Cary Hart wrote:
> Perhaps a tad OT. From the command line, if I do "export FOO='bar'" and
> then do export -p, the result is as expected.
> 
> However, if I do the same thing in a script:
> #!/bin/bash
> export FOO="bar"
> 
> . . . it does not create the variable. export -p and it's not there.
> 
> Where am I going wrong? What don't I get? 
> 
> Thanks.

Are you expecting $FOO to be available in the parent context after the
script runs?  A sub-shell cannot effect changes in the parent
environment by adding a variable.  They may be able to chenge the value
of an exported variable handed to them.

If you want the script to change the current context you have to "."
source it into the current shell.  e.g.
	. myscript.sh


-- 
G.Wolfe Woodbury     `- -'
RHCT                   U
The Line Eater is a boojum!



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux