How to have function local variable but must behave just a simple /
plain variable which is retaining its value all the time, no matter
how many times exit and enter the function
Sort of like a function-scoped static variable in C?
int counter() {
static int n = 0;
return ++n;
}
Zsh doesn't have the equivalent. You'll have to use a global parameter.