Both types remove any external versions of the variables from the scope.
The =
assigns a null value to the variable, whereas the bare form leaves the variable unset.
For example:
A=30
B=30
function foo()
{
local A B=
echo A - $A
echo B - $B
echo A :- ${A:-minusA}
echo B :- ${B:-minusB}
echo A :+ ${A:+plusA}
echo B :+ ${B:+plusB}
echo A hash ${#A}
echo B hash ${#B}
echo A - ${A-minusA}
echo B - ${B-minusB}
echo A + ${A+plusA}
echo B + ${B+plusB}
## Modifies variable
echo A := ${A:=eqA}
echo B := ${B:=eqB}
echo A - $A
echo B - $B
}
foo
Output:
A -
B -
A :- minusA
B :- minusB
A :+
B :+
A hash 0
B hash 0
A - minusA
B -
A +
B + plusB
A := eqA
B := eqB
A - eqA
B - eqB
You can see the section:
echo A - ${A-minusA}
echo B - ${B-minusB}
echo A + ${A+plusA}
echo B + ${B+plusB}
is different for A and B.