Workaround; As indicated, to put the variable in quotation marks, as in command: /app/script.sh "${BAR:?BAR variable missing}". Then it works, as expected.
I am unsure about https://github.com/containers/podman-compose/issues/848, as you can see it also seems to treat foo and bar differently when set, so this may be a related issue. Note how BAR is never read, although it is certainly being set.
Describe the bug The required variable syntax (
${BAR:?BAR variable missing}
) is not resolved when not in quotation marks since v1.1.0.To Reproduce Here is an full example/MWE: https://gist.github.com/rugk/ac09b28bc9de833e772cb1509364b421 (You can just git clone the gist.)
The relevant part is:
script.sh
:(copied/adjusted from https://github.com/containers/podman-compose/issues/848, which may or may not be related)
BAR
can be there or not, in any case it is not handled at all.Expected behavior AFAIK this has worked in versions before:
BAR
is not set, show an errorBAR variable missing
BAR
is set, expand it with it's valueAFAIK this is the correct syntax/usage for required variables.
Actual behavior It is not expanded, and just passed/treated as is.
In
podman-compose-test
:Output
Environment:
Additional context
Workaround; As indicated, to put the variable in quotation marks, as in
command: /app/script.sh "${BAR:?BAR variable missing}"
. Then it works, as expected.I am unsure about https://github.com/containers/podman-compose/issues/848, as you can see it also seems to treat foo and bar differently when set, so this may be a related issue. Note how
BAR
is never read, although it is certainly being set.