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

Re: export question



On Sat, Jan 06, 2007 at 10:06:02PM -0500, Tony Heal wrote:
> Here is the problem. What you suggest will place the variable in the
> environment, but that is what export is supposed to do.
> 
> >From the man for bash
> export [-fn] [name[=word]] ...
> export -p
>     The supplied names are marked for automatic export to the environment of
> subsequently executed commands.
> 
> Export should allow me to use the variable in other scripts, but it does not
> seem to be doing what it does if used in the profile.
> 
> That is what I am confused about.
> 
When you execute your script, a new process is created with your current
shell as its parent.  In the *new* process, which starts with a copy of
the parent's environment, the export is executed and it works.  Once the
script finishes executing, the *new* process goes away and so do any
changes to the environment.  Now, when you *source* the file (i.e., that
is not execute it) it is as though you were typing the commands yourself
in your *current* shell.  In that case it will work.  Note, however,
that the change is only in effect for that shell and any processes
spawned by it.

Regards,

-Roberto

-- 
Roberto C. Sanchez
http://people.connexer.com/~roberto
http://www.connexer.com

Attachment: signature.asc
Description: Digital signature


Reply to: