You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a variable interpolation is nested inside a ${A:+}-style interpolation construct for the same variable, compose emits a "variable is not set" warning, even though the nested evaluation isn't supposed to be evaluated.
WARN[0000] The "A" variable is not set. Defaulting to a blank string.
[+] Running 1/1
✔ Container docker-compose-repro-test-1 Recreated 0.1s
Attaching to test-1
test-1 | B
test-1 exited with code 0
The warning is a false positive: the nested ${A}, expression should only be evaluated if A is defined, which it isn't.
bash variable support is way more elaborated that compose one 😅
also, AFAICT bash never warn you about empty variable, just defaults to blank, so the comparison is pretty limited here.
What is the actual use-case that revealed this limitation ? Your example is easily replaceable with a default value in variable
This is the actual use case - I want the end result to be ${A},B when A is set, and B when it isn't. It's not solvable with just a default value, since the comma should not be present when A is undefined.
Description
When a variable interpolation is nested inside a
${A:+}
-style interpolation construct for the same variable,compose
emits a "variable is not set" warning, even though the nested evaluation isn't supposed to be evaluated.Steps To Reproduce
Create
compose.yml
as follows:Run
docker compose up
. It prints the following:The warning is a false positive: the nested
${A},
expression should only be evaluated ifA
is defined, which it isn't.Compose Version
Docker Environment
Anything else?
For comparison, in bash an equivalent scenario works as expected:
The
-u
option prohibits interpolating undefined variables, but no error is produced.The text was updated successfully, but these errors were encountered: