mise's ${VAR:-fallback} deviates from POSIX shell :- semantics
#10444
-
|
Follow-up to: SummaryWith
Reproduced on 2026.6.6 and 2026.6.9 (linux-x64). Repro
[settings]
env_shell_expand = true
[env]
BUG1 = "${BUG1:-fallback}"
BUG2 = "${UNSET_VAR:-$OTHER}"$ mise version
2026.6.9 linux-x64 (2026-06-14)
# BUG1 — empty string should coalesce to the default
$ BUG1='' mise env | grep BUG1
set -gx BUG1 '' # ← expected: fallback
$ BUG1='' sh -c 'echo ${BUG1:-fallback}'
fallback # ← POSIX
# BUG2 — fallback branch should be expanded
$ OTHER=hello mise env | grep BUG2
set -gx BUG2 '$OTHER' # ← expected: hello
$ OTHER=hello sh -c 'echo ${UNSET_VAR:-$OTHER}'
hello # ← POSIX( Why it mattersCI systems commonly forward variables unconditionally, so an unset variable arrives as an empty string, not as truly unset. For example, GitHub Actions: env:
IMAGE_OWNER: ${{ vars.IMAGE_OWNER }} # becomes "" when the repo var is unsetWith the empty-coalesce gap, IMAGE_OWNER = "{% set v = get_env(name='IMAGE_OWNER', default='') %}{% if v %}{{ v }}{% else %}thechangelog{% endif %}"Expected
(If |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Thanks for the detailed repro. I opened #10445 to make env shell expansion match the documented/POSIX-style behavior for these cases: Validated with This comment was generated by an AI coding assistant. |
Beta Was this translation helpful? Give feedback.
Thanks for the detailed repro. I opened #10445 to make env shell expansion match the documented/POSIX-style behavior for these cases:
${VAR:-default}now falls back when the value is empty,${VAR-default}keeps empty strings as set, and fallback branches like${UNSET:-$OTHER}are shell-expanded.Validated with
mise run test:e2e e2e/env/test_env_shell_expandandmise run format.This comment was generated by an AI coding assistant.