This is the mail archive of the cygwin 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: setting environment variables from a bash script


Aaron Gray wrote:

> Is it possible to set an environment variable using a bash script and for
> that variable to be able to be seen within bash once the script is
> finnished.

It's impossible for a child process to modify the environment of its
parent.  By executing the file as a script you spawn a shell subprocess,
meaning the changes to the environment are for that process only.

You can get around that by sourcing the script instead of executing it,
because in that case you tell the current shell to read and execute the
commands in the file rather than spawning a subprocess to do it.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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