Shell – How to restore the changes to shell variable

environment-variablesshell

For the purpose of an experiment…

Suppose I did this

bash="unset DISPLAY; export DISPLAY"

so I can make DISPLAY undefined. How can I restore the original value set? Or at least know what it was?

Best Answer

In general you write it down before hand.

If you're asking about this in theory, then you simply store the old value somewhere else before modifying it, then put it back whenever you want.

If you're asking about this because now you're screwed and are hoping that there's something that will bail you out, then I have bad news for you...

Related Question