Skip to content

Instantly share code, notes, and snippets.

@binki
Last active February 29, 2016 16:13
Show Gist options
  • Save binki/ab767e2128e1bc6b1ac0 to your computer and use it in GitHub Desktop.
Save binki/ab767e2128e1bc6b1ac0 to your computer and use it in GitHub Desktop.
Undelayed expansion use case?
SETLOCAL
CALL test.cmd
IF ERRORLEVEL 1 (
SET TESTRET=1
) ELSE (
: # Do something with some envvars that test.cmd set that
: # we want to protect our own cmd code from.
)
: # Rely on undelayed expansion semantics to communicate variables
: # out of the SETLOCAL/ENDLOCAL :-D. Though, I suspect that if
: # the variable contains a closing paren, this’ll break.
IF 0 == 0 (
ENDLOCAL
SET TESTRET=%TESTRET%
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment