cargo-make: Conditional env vars shouldn't unset when the predicate fails

Feature Description

The docs describe it as possible to set environment variables through conditions, but this doesn’t actually work to either/or variables

For example, the following:

MAKEFILE_NIGHTLY_OVERRIDE = { script = "echo MAKEFILE_NIGHTLY_OVERRIDE" } # Get it from the bash/cmd env
MAKEFILE_NIGHTLY = { condition = { env_set = ["MAKEFILE_NIGHTLY_OVERRIDE"]}, value = "1"}
MAKEFILE_NIGHTLY = { condition = { env_not_set = ["MAKEFILE_NIGHTLY_OVERRIDE"]}, value = "2"}

will not conditionally set MAKEFILE_NIGHTLY based on the value of MAKEFILE_NIGHTLY_OVERRIDE. rather it will set MAKEFILE_NIGHTLY to 2 if the override variable is set and 1 if it isn’t.

This is because the condition evaluating to false ends up unsetting the variable.

Describe The Solution You’d Like

It would be nice if conditions would only touch (set or unset) the variable if the condition is true.

(It would also work if you could use duckscript in env vars since then you can just use the if there)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (21 by maintainers)

Most upvoted comments

@Manishearth the changes (toolchain) are now officially released

It works, thanks!