bug in XP cmd shell

  • Thread starter Thread starter Jim Michaels
  • Start date Start date
J

Jim Michaels

in the cmd shell help (from cmd shell do set /?), it gives the example

set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "%VAR%" == "after" @echo If you see this, it worked
)

the "if you see this, it worked" never shows.
I am using XP Pro SP3 32-bit on an HT processor that thinks it's a
dual-core.
 
in the cmd shell help (from cmd shell do set /?), it gives the example

    set VAR=before
    if "%VAR%" == "before" (
        set VAR=after
        if "%VAR%" == "after" @echo If you see this, it worked
    )

the "if you see this, it worked" never shows.
I am using XP Pro SP3 32-bit on an HT processor that thinks it's a
dual-core.

oops. that example should be

set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "!VAR!" == "after" @echo If you see this, it worked
)

the ! causes delayed expansion at execution.

apparently delayed expansion is not enabled by default...
 
Jim Michaels said:
in the cmd shell help (from cmd shell do set /?), it gives the example

set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "%VAR%" == "after" @echo If you see this, it worked
)

the "if you see this, it worked" never shows.
I am using XP Pro SP3 32-bit on an HT processor that thinks it's a
dual-core.

Jim Michaels said:
oops. that example should be
set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "!VAR!" == "after" @echo If you see this, it worked
)
the ! causes delayed expansion at execution.
apparently delayed expansion is not enabled by default...

Jim,
Did you enable delayed environment variable expansion via
CMD /v:on
 
Back
Top