[Gllug] ADVERT: Shell Scripting book
nix at esperi.org.uk
Wed Jul 20 22:40:40 UTC 2011
On 20 Jul 2011, Alain Williams verbalised:
> On Wed, Jul 20, 2011 at 11:16:46PM +0100, Steve Parker wrote:
>> I think that this is where I was unclear. I should have made explicit
>> that the state of the given process is modified, but not exported to the
>> current process's environment which is what is passed on to its children.
> That is not right either. You talk about exporting to the shell's own environment,
> the shell does not do that - it doesn't change its own environment.
This is hard to define. If you say
then the effect is *as if* the current shell's environment is changed
(and similarly if you change an already-exported variable).
The shell may or may not actually change its Unix environment, but this
is sufficiently annoying to do reliably (with a realloc()-and-wholesale-
copy often being required) that most modern shells don't do so, but
merely copy the environment into an internal data structure (which also
holds shell variables, with env vars tagged with an exported flag). The
original Bourne shell *did* change its actual environment on every
change of an exported variable.
The only situation in which a subprocess's environment is changed
(generally via execve() or one of the other environ-pointer-taking
exec*() functions) is when an environment variable is placed into
a single process's environment via the
NULL && (void)
Gllug mailing list - Gllug at gllug.org.uk
More information about the GLLUG