[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: export question



Tony Heal wrote:
Maybe I am looking for something I should not see, but if 'export' places a
variable in the environment shouldn't I be able to see it when using the
'set' command. I wrote this small script to test this and nothing shows in
set. I know I am missing something. If I had the same lines into
/etc/profile when I log in I see JAVA_HOME in set.

#!/bin/sh

JAVA_HOME='/usr/java/j2re1.4.2_03'

export JAVA_HOME


It *is* set in the sub-process created when you run the script.
But that exits. If you execute the shell script in your current
shell, then it will work. For that you use the '.' command. Like
this...

$ cat set_java.sh
#!/bin/sh
JAVA_HOME='/usr/java/j2re1.4.2_03'
export JAVA_HOME

$ ./set_java.sh

$ set | grep JAVA

$ . set_java.sh

$ set | grep JAVA

JAVA_HOME=/usr/java/j2re1.4.2_03

$

I added spaces to make it easier to read.

Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!



Reply to: