4
# Whether a variable has been declared
5
#+ affects triggering of the default option
6
#+ even if the variable is null.
9
echo "username0 has been declared, but is set to null."
10
echo "username0 = ${username0-`whoami`}"
15
echo username1 has not been declared.
16
echo "username1 = ${username1-`whoami`}"
20
echo "username2 has been declared, but is set to null."
21
echo "username2 = ${username2:-`whoami`}"
23
# Will echo because of :- rather than just - in condition test.
24
# Compare to first instance, above.
32
# variable has been declared, but is set to null.
34
echo "${variable-0}" # (no output)
35
echo "${variable:-1}" # 1
40
echo "${variable-2}" # 2
41
echo "${variable:-3}" # 3