${var:-default}
means $var if $var is defined and otherwise "default"
${var:+value}
means if $var is defined use "value"; otherwise nothing
The second one might seem a little wierd, but your code snippet shows a typical use:
${debian_chroot:+($debian_chroot)}
This means "if $debian_chroot is defined, then insert it inside parentheses."
Above, "defined" means "set to some non-null value". Unix shells typically don't distinguish between unset variables and variables set to an empty string, but bash can be told to raise an error condition if an unset variable is used. (You do this with set -u
.) In this case, if debian_chroot
has never been set, $debian_chroot
will cause an error, while ${debian_chroot:-}
will use $debian_chroot
if it has been set, and otherwise an empty string.