${uno-}
is an example of providing a default value in case the parameter uno
is unset.
If uno
is unset, we get the string that follows the -
:
$ unset uno
$ echo ${uno-something}
something
If uno
is merely the empty string, then the value of uno
is returned:
$ uno=""
$ echo ${uno-something}
$
If uno
has a non-empty value, of course, then that value is returned:
$ uno=Yes
$ echo ${uno-something}
Yes
Why use ${variable-}
?
When proper operation of a script is important, it is common for the script writer to use set -u
which generates an error message anytime an unset variable is used. For example:
$ set -u
$ unset uno
$ echo ${uno}
bash: uno: unbound variable
To handle the special cases where one may want to suppress this message, the trailing -
can be used:
$ echo ${uno-}
$
[Credit for finding that the OP's full code used set -u
and its importance to this question goes to Benjamin W.]
Documentation
From man bash
When not performing substring expansion, using the forms documented
below (e.g., :-), bash tests for a parameter that is unset or null.
Omitting the colon results in a test only for a parameter that is
unset.
${parameter:-word}
Use Default Values. If parameter is unset or null, the expansion of word is substituted. Otherwise, the value
of parameter is substituted. [emphasis added]