How does "${2:-}" work in an 'if-then-else example' below? Somehow I cannot help but think that being ${2:-} it means the second argument, but I am curious what the colon(:) and dash(-) after the digit 2 mean?
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
default=Y
elif [ "${2:-}" = "N" ]; then
prompt="y/N"
default=N
else
prompt="y/n"
default=
fi
read -p "$1 [$prompt] " REPLY </dev/tty
${2:-}
differs from${2}
which also has an empty expansion if it's empty or unset. – Gilles 'SO- stop being evil' May 12 '16 at 22:24set -u
in place (: – DopeGhoti May 12 '16 at 22:30