The :- operator in bash expands the right-hand-side when the left-hand-side is undefined or empty. logback only expands the RHS when the LHS is undefined. Thus, a system property that has been defined but not assigned (e.g., -Ddefined) does not trigger default expansion, because such parameters actually have the empty string as their value.
Chapter 3 of the documentation states that this operator is based on the operator with the same name in Bash. Bash, however, expands on blank:
X=""
echo $
{X:-3}
will echo 3.
I would prefer that logback adopt the same semantics as Bash; but if this is not possible due to backward-compatibility reasons, the documentation should be updated to point out that this differs from Bash for this corner case.
|