$ mySite="superuser" $ readonly mySite $ unset mySite bash: unset: mySite: cannot unset: readonly variable
How can we delete mySite, as it is a readonly variable?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
Walker Hale IV's solution can be expressed in a much shorter fashion using options available in more recent versions of
gdb --batch-silent --pid=$$ --eval-command='call unbind_variable("mySite")'
Again, this is dark magic that should be kept well away from production environments.
This is dark magic. It uses
gdb to tell the
bash process to clear the variable by calling an internal C function.
mySite="superuser" readonly mySite gdb -n <<EOF >>/dev/null 2>&1 attach $$ call unbind_variable("mySite") detach quit EOF
You should never have this in production. I have it in my .bashrc. 😉