SeeknInspYre
SeeknInspYre

Reputation: 450

Are environment variables associative?

In windows 7, if you do something like this in the command line:

X=Debug

Y=ABC\%X%

then...

X=Release

Y=?

Upvotes: 2

Views: 100

Answers (1)

jimhark
jimhark

Reputation: 5046

On Windows this:

set X=Debug
set Y=ABC\%X%
X=Release
echo %Y%

Prints:

ABC\DEBUG'

Here's what happens, step by step:

set X=Debug

Environment variable X is set to the value 'Debug'

set Y=ABC\%X%

Variable expansion converts the command to:

set Y=ABC\Debug

And this command is executed. No association is retained between X and Y.

set X=Release

Has no effect on Y

echo %Y%

Displays:

ABC\Debug

Upvotes: 2

Related Questions