How do you set the value of MAGIC? Enter the next construct, which is a similar construct but the minus sign is replaced with the equals sign:

unset $MAGIC
echo ${MAGIC:='zingzangzoom'}
echo $MAGIC

If you run the above, you will notice that the variable MAGIC now contains the value 'zingzangzoom'. So this new construct means:

If the variable IS NULL or UNSET, then assign the new value to the variable, otherwise if the variable is already set, don't touch the value.

To satisfy ourselves that this is actually the case, run the following:

echo ${MAGIC:='zingzangzoom'}
echo $MAGIC

which should produce abracadabra.

unset MAGIC
echo ${MAGIC:='zingzangzoom'}
echo $MAGIC

Will produce zingzangzoom.

Where would we use this? Again we could use it with our EDITOR environmental variable:


Now if EDITOR was NULL or UNSET, then it would assign the value '/bin/vi' to EDITOR.

However if you had run:


then EDITOR would remain with the value nano.