This is an effect of the CALL
command.
The CALL
command doubles all carets in one of the batch parser phases.
Normally you wouldn't see this, as the carets will be used as an escape charater directly after the doubling.
See this
call echo ^^^^
call call echo ^^^^
call call call echo ^^^^
call echo "^^^^"
call call echo "^^^^"
call call call echo "^^^^"
Output
^^
^^
^^
"^^^^^^^^"
"^^^^^^^^^^^^^^^^"
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
But how do you can escape your pipe character?
You can't!
But you can add a caret remover in your function.
:runShellCmd
setlocal EnableDelayedExpansion
set "param=%~1"
set param
set "param=!param:^^=^!"
for .... ('!param!')
Or you could use an escaping trick when calling your function.
set "caret=^"
CALL :runShellCmd "echo Jatin Kumar %%caret%%| find /c /i "
This works, as the %%caret%%
will be expanded after the CALL caret doubling phase
.