environment variable issue in shell

Posted by George2 on Super User See other posts from Super User or by George2
Published on 2010-05-22T10:48:27Z Indexed on 2010/05/22 10:51 UTC
Read the original article Hit count: 309

I am using Red Hat Linux Enterprise 5. I know the theory that -- using export to set environment variable, the environment variable will apply to current and child environment, but without using export to set environment variable, the environment variable will only apply to the current environment.

My confusion is, what is the exact definition of "child environment" and "current environment"? For example,

$ var1=123 $ echo "Hello [$var1]"

the value of var1 (which is 123) is printed in shell, but I think echo is a command invoked by current shell, and it (the echo command) should be a child environment of current shell and the value of var1 should not (because not using export var1=123) impact echo. Any comments?

Thanks in advance!

© Super User or respective owner

Related posts about linux

Related posts about shell