First, we run this in Windows cmd
:
set haserror=FALSE
Followed by:
set haserror=TRUE && echo [status: %haserror%] && if %haserror% EQU FALSE echo Second
The result is:
[status: FALSE ]
Second
Seems like when chaining the commands, anything that sets an env
variable is ignored by the next commands. The variable is actually set, but the change is only picked up when the command is executed for the second time.
set haserror=TRUE && echo [status: %haserror%] && if %haserror% EQU FALSE echo Second
Produces the desired result this time:
[status: TRUE ]
Is there a way to propagate the env variable immediately so the next command in the chain picks up the change?