Scope of "setenv" in csh Versus "export" in bash Scope of "setenv" in csh Versus "export" in bash shell shell

Scope of "setenv" in csh Versus "export" in bash


Exporting a variable means that a copy of that variable is placed into the environment of any newly created child processes. It is a copy of the variable; if the child process modifies the variable, the parent does not see the modification. Moreover, if a child exports a variable, it does not become visible in the parent.

Hence, your two cases are asymmetrical. When you start in csh, export a variable, and then start bash, bash sees the exported variable. When you then export a new variable in bash and exit from bash to go back to csh, all of the variables created in the bash session disappear.

If you were to export a variable in bash and then start up a child csh (by typing csh), you would almost certainly see the exported variable.