It's not the "default", per-se. It's simply that a child process can never affect the environment of its parent, no matter what you do. But any variable that's been given the "export" value will be inherited by any sub-shells launched, and the subshell version of the variable can be changed. When the sub-process is closed, its environment, including any changes, is lost, while the environment of the parent shell is still there unaltered.
In simple terms, changes can propagate down, but never up.
By the way, any variable can be set to read only (in bash) with "declare -r variablename", although again the setting will only affect the current shell level and its sub-processes. Be careful with the read-only value though, particularly with environmental variables, because once set, it can never be unset for as long as that process exists.
|