(view source code of testcallescapedstring.bat as plain text)
@ECHO OFF
IF "%~1"=="" (
CLS
ECHO Demo script showing how CALL adds its own caret escape characters to arguments
ECHO.
ECHO Note the loss of the percent sign even when doublequoted
ECHO Command : ECHO "%%A^("
ECHO Expected output : "%%A^("
ECHO Actual output : "%A^("
ECHO.
ECHO Command : ECHO %%A^^(
ECHO Expected output : A^(
ECHO Actual output : %A^(
ECHO.
ECHO Command: CALL :Subroutine "%%A^("
CALL :Subroutine "%A^("
ECHO Command: CALL "%%~f0" "%%A^("
CALL "%~f0" "%A^("
ECHO.
) ELSE (
ECHO.
ECHO Start of rerun, note the automatically added escape characters and loss of percent signs
ECHO Command : ECHO "%%~1"
ECHO Expected output : "%%A^("
ECHO Actual output : "%~1"
ECHO.
ECHO Command: ECHO.%%~1
ECHO Expected output : A(
ECHO Actual output : %~1
ECHO End of rerun
ECHO.
)
GOTO:EOF
:Subroutine
ECHO.
ECHO Start of Subroutine, note the automatically added escape characters and loss of percent signs
ECHO Command : ECHO "%%~1"
ECHO Expected output : "%%A^("
ECHO Actual output : "%~1"
ECHO.
ECHO Command : ECHO.%%~1
ECHO Expected output : A(
ECHO Actual output : %~1
ECHO End of Subroutine
ECHO.
GOTO:EOF
page last modified: 2024-04-16; loaded in 0.0062 seconds