I have a variable
pathname="xxx"
I have set it as an enviroment variable using
export pathname="xxx"
How do I "reverse" it and make the variable not exported?
I have a variable
pathname="xxx"
I have set it as an enviroment variable using
export pathname="xxx"
How do I "reverse" it and make the variable not exported?
In
bash
you can usetypeset
(or its synonymdeclare
) to remove the export attribute.(The same command works in
zsh
andksh
. You can usedeclare
in eitherbash
orzsh
, but notksh
, and it is probably more common to see it used in practice.)As far as I know, there is no way to remove the export attribute in POSIX shell. (
dash
is a prominent example of a shell which does not provide an extension such asdeclare
.) You would need to save the value in a temporary value, unset the original, then reset the original:(
dash
, at least, explicitly documents that the only way to remove the export attribute is to unset it.)