[23.0 backport] stack/loader: Ignore cmd.exe special env variables by thaJeztah · Pull Request #4083 · docker/cli (original) (raw)


On Windows, ignore all variables that start with "=" when building an environment variables map for stack.

For MS-DOS compatibility cmd.exe can set some special environment variables that start with a "=" characters, which breaks the general assumption that the first encountered "=" separates a variable name from variable value and causes trouble when parsing.

These variables don't seem to be documented anywhere, but they are described by some third-party sources and confirmed empirically on my Windows installation.

Useful sources:
https://devblogs.microsoft.com/oldnewthing/20100506-00/?p=14133
https://ss64.com/nt/syntax-variables.html

Known variables:

All these variables can be safely ignored because they can't be deliberately set by the user, their meaning is only relevant to the cmd.exe session and they're all are related to the MS-DOS/Batch feature that are irrelevant for us.

- What I did

- How I did it

- How to verify it
TestBuildEnvironment test

- Description for the changelog
Fix docker stack deploy failing when running from cmd.exe on Windows

- A picture of a cute animal (not mandatory but encouraged)