Export
Chris Torek
chris at mimsy.UUCP
Fri Jul 28 21:20:38 AEST 1989
In article <29882 at cci632.UUCP> tvf at cci632.UUCP (Tom Frauenhofer) writes:
>How does the shell mechanism to export a variable work? Are there two
>environment lists, one public, one private, that a given process uses?
The Bourne shell (sh), upon startup, copies its environment to an
internal table. It also copies it to another table of shell variables.
The shell variables are all marked `not exported'.
The `export' built-in looks up the name(s) to be exported in the shell
variable table, and sets the `to be exported' flag. The `name=value'
code checks the `exported' flag, and if set, copies the new value into
the table of environment variables.
Thus, inside sh, there are three tables:
- the initial environment (on the stack above main()'s frame)
- the environment for new processes
- all shell variables
(Some of the storage for the strings is shared.) Most processes have
only the first.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.unix.wizards
mailing list