Docker Community Forums

Share and learn in the Docker community.

FR: Use of nested variables in default expansion "${FOO:-$BAR}"


(Ifreeman) #1

There is an open PR on Github that I’d be very interested in getting accepted (here). The basic gist is that docker-compose currently doesn’t support recursive variable expansion such as ${FOO:-$BAR} for setting defaults based on the contents of other variables. The current behavior is to expand to the literal string $BAR when FOO isn’t defined. A reviewer has suggested that implementing this would “break” existing behavior, but I can’t imagine any use case where defaulting to the literal string $BAR is useful.

If anyone can provide an actual example of this being used in a way that actually expects the un-expanded literal string in the default, in real code (not hypotheticals), I would really like to see it.

Thanks