Skip to content

fix: respect empty values in colon-plus substitutions - #76

Open
sean0407 wants to merge 1 commit into
a8m:masterfrom
sean0407:codex/fix-empty-alternate-expansion
Open

sean0407 wants to merge 1 commit into
a8m:masterfrom
sean0407:codex/fix-empty-alternate-expansion

Conversation

@sean0407

Copy link
Copy Markdown

Summary

${VAR+word}   -> use word when VAR is set
${VAR:+word}  -> use word only when VAR is set and nonempty
  • Closes ${var:+FOO} mishandles empty vars #53.
  • Keep + set-only behavior and make :+ check the variable's value before expanding its alternate word.
  • Add regression coverage for an empty variable with a nonempty alternate, including that the alternate is not evaluated when the variable is empty.

Evidence

  • Before: the isolated regression failed: ${EMPTY:+hello} returned hello instead of an empty string.
  • After: the regression and parser suite pass.
  • Changed files: parse/node.go, parse/parse_test.go.
  • Checks run: gofmt check passed; go test passed; go test ./parse passed; go test -vet=off ./... passed; git diff --check passed. The project patch policy accepted 2 files and no binary changes.

Merge Danger

Door: one-way

Blast Radius: Low

The change affects only ${VAR:+word} when VAR is set to an empty value. ${VAR+word} remains set-only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

${var:+FOO} mishandles empty vars

1 participant