1

If I accidentally set a readonly variable like this:

declare -r VAR="foo"

When I should have set it to bar. How can I set it to bar?

Thanks

jackw11111
  • 1,457
  • 1
  • 17
  • 34

1 Answers1

1

declare, as any other statement that modifies a variable within a shell, only does so within the current environment. As the shell does not somehow save its environment on eixst and load it again when restarted, you can just close your shell and open a new one and you'lll have your initial environment back.

It's actually way harder to make changers persist in a shell than to reset them...

Johannes H.
  • 5,875
  • 1
  • 20
  • 40