Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for testcallescapedstring.bat

(view source code of testcallescapedstring.bat as plain text)

  1. @ECHO OFF
  2. IF "%~1"=="" (
  3. 	CLS
  4. 	ECHO Demo script showing how CALL adds its own caret escape characters to arguments
  5. 	ECHO.
  6. 	ECHO Note the loss of the percent sign even when doublequoted
  7. 	ECHO Command         : ECHO "%%A^("
  8. 	ECHO Expected output : "%%A^("
  9. 	ECHO Actual output   : "%A^("
  10. 	ECHO.
  11. 	ECHO Command         : ECHO %%A^^(
  12. 	ECHO Expected output : A^(
  13. 	ECHO Actual output   : %A^(
  14. 	ECHO.
  15. 	ECHO Command: CALL :Subroutine "%%A^("
  16. 	CALL :Subroutine "%A^("
  17. 	ECHO Command: CALL "%%~f0" "%%A^("
  18. 	CALL "%~f0" "%A^("
  19. 	ECHO.
  20. ) ELSE (
  21. 	ECHO.
  22. 	ECHO Start of rerun, note the automatically added escape characters and loss of percent signs
  23. 	ECHO Command         : ECHO "%%~1"
  24. 	ECHO Expected output : "%%A^("
  25. 	ECHO Actual output   : "%~1"
  26. 	ECHO.
  27. 	ECHO Command: ECHO.%%~1
  28. 	ECHO Expected output : A(
  29. 	ECHO Actual output   : %~1
  30. 	ECHO End of rerun
  31. 	ECHO.
  32. )
  33. GOTO:EOF
  34.  
  35. :Subroutine
  36. ECHO.
  37. ECHO Start of Subroutine, note the automatically added escape characters and loss of percent signs
  38. ECHO Command         : ECHO "%%~1"
  39. ECHO Expected output : "%%A^("
  40. ECHO Actual   output : "%~1"
  41. ECHO.
  42. ECHO Command         : ECHO.%%~1
  43. ECHO Expected output : A(
  44. ECHO Actual   output : %~1
  45. ECHO End of Subroutine
  46. ECHO.
  47. GOTO:EOF

page last modified: 2024-04-16; loaded in 0.0187 seconds