I have this function in my .zshrc:
activated=false
function test_toggle() {
if [ $activated=false ]; then
echo "WAS FALSE"
activated=true
else
echo "WAS TRUE"
activated=false
fi
}
I'd like the function to toggle the state of var activated
between false
and true
.
But if I open a terminal and run the function I only get this:
$ test_toggle
WAS FALSE
$ test_toggle
WAS FALSE
$ test_toggle
WAS FALSE
How can I make the function use and change the variable: activated
from parent scope correctly?