This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question re. export environment variable

On Thu, 20 Feb 2003, Fred Ma wrote:

> Hello,
> I'm using cygwin bash 2.05b-8 (it's actually gnu).
> I thought that $HOSTNAME was an environment
> variable.  When I run gnu make (I'm pretty
> sure this is not a make problem), $(HOSTNAME)
> is empty.  It gets fixed if I do "export HOSTNAME"
> before running make.
> Is there a way to check if the export command
> has been applied to $HOSTNAME?  Does the
> actual transcription of $HOSTNAME's value to
> the environment happen only once, when
> "export" is applied, or is there a continual
> monitoring an mirroring of changes to $HOSTNAME
> forever after applying "export"?
> Fred


I'm afraid you might be confused about what "exporting" a variable means.
Bash maintains an "environment", which contains the values of all the
variables it's using.  When bash spawns a child, that child inherits those
variables from the parent's environment that are "exported".  Thus, if you
export HOSTNAME, the child will get the current value of HOSTNAME.  If you
then change HOSTNAME in the parent, the child *will not* see the change.
However, if you spawn another child, that new child *will* see the new

BTW, "export" with no variable name will print out the list of all
variables that are exported from the current shell.  And, if you want to
make sure it's exported, "export HOSTNAME" can do no harm.  But both this
and the above are off-topic for the Cygwin list, and could have been found
by a simple perusal of "man bash".
      |\      _,,,---,,_		pechtcha at cs dot nyu dot edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor at watson dot ibm dot com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Oh, boy, virtual memory! Now I'm gonna make myself a really *big* RAMdisk!
  -- /usr/games/fortune

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]