summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compose/config/interpolation.py5
-rw-r--r--tests/unit/config/interpolation_test.py12
2 files changed, 14 insertions, 3 deletions
diff --git a/compose/config/interpolation.py b/compose/config/interpolation.py
index 59a567bb..8845d73b 100644
--- a/compose/config/interpolation.py
+++ b/compose/config/interpolation.py
@@ -133,9 +133,8 @@ class TemplateWithDefaults(Template):
braced = mo.group('braced')
if braced is not None:
sep = mo.group('sep')
- result = self.process_braced_group(braced, sep, mapping)
- if result:
- return result
+ if sep:
+ return self.process_braced_group(braced, sep, mapping)
if named is not None:
val = mapping[named]
diff --git a/tests/unit/config/interpolation_test.py b/tests/unit/config/interpolation_test.py
index 2ba698fb..0d0e7d28 100644
--- a/tests/unit/config/interpolation_test.py
+++ b/tests/unit/config/interpolation_test.py
@@ -420,3 +420,15 @@ def test_interpolate_unicode_values():
interpol("$FOO") == '十六夜 咲夜'
interpol("${BAR}") == '十六夜 咲夜'
+
+
+def test_interpolate_no_fallthrough():
+ # Test regression on docker/compose#5829
+ variable_mapping = {
+ 'TEST:-': 'hello',
+ 'TEST-': 'hello',
+ }
+ interpol = Interpolator(TemplateWithDefaults, variable_mapping).interpolate
+
+ assert interpol('${TEST:-}') == ''
+ assert interpol('${TEST-}') == ''