Last active
August 29, 2015 14:00
-
-
Save davidruhmann/11293083 to your computer and use it in GitHub Desktop.
[Batch] My Expand Routine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
:: This works by exploiting the set and defined commands. If the Var is null, | |
:: then the set command will fail, the error message is caught, and the defined | |
:: command will fail because there should NEVER exist a variable named =. | |
:: Usage: call :Expand A %~1 0 | |
:: The default works by exploiting how commands are parsed. If parameter 1 is | |
:: empty, then 0 will be passed to the routine as Value. | |
:: Author: David Ruhmann | |
:Expand <Var> [Value] [Default] | |
2>nul set "%~1=%~2" | |
if defined %~1 = exit /b 0 | |
exit /b 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment