Simon Geard wrote:
> On Thu, 2009-08-13 at 10:56 -0700, Smartboy wrote:
>
>   
>> That is one of the biggest flaws in bash. I ran into the same problem
>> a while back when trying to make a script of mine more modular by
>> dividing it up into several files. Only way around it that I know of
>> is to export it into a file, then call that file again after your
>> script has finished. If anyone knows a better way, please mention
>> it. :)
>>     
>
> It's not a flaw in bash - it's a fundamental of Unix. Environment
> variables are per-process, and so setting them in one bash process can
> have no effect on any other process.
>
> The exception to that being that when a new process is started, it does
> so with a copy of the parent's environment. Thus, exporting http_proxy
> from a shell script makes it's value available to any other processes
> started by that script, but has no effect on the shell that started it.
>
>
> As to solutions - if the script in question is simple, the easiest way
> is to turn it into a bash shell function. Such functions are run within
> the shell, and so can set variables that will stick around in that
> shell. If you define something like the following in .bash_profile:
>
> set_proxy() {
>   export http_proxy=http://127.0.0.1:5865
> }
>
> you can then run set_proxy as a command to set the variable.
>
> Simon.
>   
Simon

Thanks so much for the explanation.  That makes a lot of sense.  The 
solution you provide works for me.

Thanks again
James
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page

Reply via email to