Code:
# monkey=chimpansee
# set | grep monkey
monkey=chimpansee
# sh
# set | grep monkey
#
# exit
# set | grep monkey
monkey=chimpansee
# export monkey
# sh
# set | grep monkey
monkey=chimpansee
Conclusion: a shell variable is only visible to that particular shell instance/process. If you start a new process/subshell, it will not inherit the shell variables of the parent shell/process unless the variable has been exported (Bourne shell) into the
environment.
For the C shell you have to use
setenv instead of
export