what does export do?

Steven W. Orr steveo at syslang.net
Fri May 20 15:24:55 UTC 2005


On Friday, May 20th 2005 at 10:52 +0100, quoth THUFIR HAWAT:

=>from the man file:
=>
=>       export [-fn] [name[=word]] ...

This might be more than you want to know, but it seems like you don't have 
a grasp of what your environmnet is to begin with.

Every programming language has the ability to access its environment and 
to set or unset its variables. The environment is copied to all child 
processes through crt0.o which is linked into every executable.

In bash

export foo=bar
echo $foo

in perl

$ENV{foo}='bar';
print $ENV{foo};

In C 

#include <stdlib.h>
    setenv ( "foo", "bar",  1 );
    printf ( "foo = %s\n", getenv ( "foo" ) );

Also, a really great place to start is to read 

man 5 environ

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net




More information about the users mailing list