OT: setting variables
Mike Erdely
mike at erdelynet.com
Wed Mar 11 04:20:56 CET 2009
On Tue, Mar 10, 2009 at 11:11:23PM -0400, Nick Guenther wrote:
> This confused me for SO LONG. The trick is to "source" the file
> instead of running it as so:
> . ./script
> or
> source ./script
>
> You'd think "EXPORT" exports the value to the entire OS, but no, it
> only exports it beyond the that command line. It sort of makes sense
> in the context that can do this to pass variables to programs:
> $ VAR=VAL ./script
>
> Unix is crazy.
Actually, read my explanation. It will make sense to you then.
Also, export exports the variable to all future sub-shells.
Try this:
$ ksh
$ FOO=bar
$ echo $FOO
bar
$ ksh
$ echo $FOO
$ exit
$ export FOO=bar
$ ksh
$ echo $FOO
bar
$ exit
$ exit
-ME
More information about the Openbsd-newbies
mailing list