Export

Steve Summit scs at adam.pika.mit.edu
Sat Jul 29 15:30:38 AEST 1989


In article <18793 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
>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.

Note the following anomaly, which I think is implied by Chris's
description: if a shell "imports" a variable (i.e. it had been
exported in a parent shell), then changes its value, that changed
value is not exported unless an explicit export is done in the
shell within which the value is changed.  Observe:

	$ var=value
	$ export var
	$ sh
	$ echo $var
	value
	$ var=nothing
	$ echo $var
	nothing
	$ sh
	$ echo $var
	value
	$ ^D
	$ echo $var
	nothing

This is a nuisance; I don't know it it's considered a "feature."
The Korn shell (at least the old version I have) "fixes" this
behavior: imported variables are implicitly exported.

                                            Steve Summit
                                            scs at adam.pika.mit.edu



More information about the Comp.unix.wizards mailing list