I seem at example 9-14.
$ echo ${1:-0}
$ 0
$ echo ${2:-32767}
$ 32767
So I cant understand...
Per the Bash Reference Manual, ยง3.5.3 "Shell Parameter Expansion":
${parameter:-word}
If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted.
So, for example, this script:
echo "${foo:-1}"
foo=2
echo "${foo:-3}"
foo=
echo "${foo:-4}"
prints
1
2
4
The syntax is ${var:-$DEFAULT}
. It means if the variable is not set or is null
, use the default value.