Hi OperatorGK,
it's not a bug, it's the well known behaviour of the call command (well known but not documented)
1. A call always doubles all carets in the line as the first phase by the parser.
Then only three more parser phases are executed.
2. The percent expansion.
3. The removing of all CR characters.
4. The special character phase where carets, ampersand, redirections are detected.
Ignored phases are:
ECHO ON phase
Delayed Expansion phase
FOR-LOOP-parameter expansion
The 4th phase also detects FOR, IF and REM and uses a different parser for those:
The 4th phase has many problems when invoked by a CALL.
The parsing/executing of FOR,REM,IF always fails.
Redirections are parsed but completly ignored.
When pipes |, multiple commands &, || or && are present, then it fails silently and nothing will be executed, also for brackets.
With the special characters and brackets you can create some strange other effects, ex.
Will execute the file 2.bat
More about this at
CALL me, or better avoid callMore about the batch parser at
SO: How does the Windows Command Interpreter (CMD.EXE) parse scripts?And some examples
Code: Select all
@echo off
setlocal EnableDelayedExpansion
set "singleCaret=^"
set "^=one caret"
set "^^=two carets"
echo #1 !singleCaret!
call echo #2 !singleCaret!
call call echo #3 !singleCaret!
call call call echo #4 !singleCaret!
echo #5 %%!singleCaret!%%
call echo #6 %%!singleCaret!%%
jeb