Page 1 of 1
Call bug using silent operator @
Posted: 16 Aug 2019 12:18
by carlos
Developing a project related to batch I found that the CALL internal command has a bug.
It not execute the command if you use the silent operator @.
For example:
Is different than:
The later not execute the command.
This can be used as another way of write a single line comment
Re: Call bug using silent operator @
Posted: 16 Aug 2019 12:51
by IcarusLives
While this is a very interesting find, it is SUBSTANTIALLY slower than using REM
Code: Select all
@echo off
echo %time%
for /l %%a in (1,1,1000000) do rem
echo %time%
echo.
echo %time%
for /l %%a in (1,1,1000000) do call @ this is a comment
echo %time%
pause
Code: Select all
14:49:04.92
14:49:06.18
14:49:06.18
14:50:37.22
Press any key to continue . . .
Re: Call bug using silent operator @
Posted: 16 Aug 2019 13:54
by dbenham
carlos wrote: ↑16 Aug 2019 12:18
Developing a project related to batch I found that the CALL internal command has a bug.
It not execute the command if you use the silent operator @.
Yes - that is known behavior. We documented that in Phase 6 of
the batch parsing rules at StackOverflow. There are a number of constructs that function as a REM if combined with CALL.
StackOverflow wrote:
Phase 6) CALL processing/Caret doubling: . . .
- . . .
- Remove the first CALL so multiple CALL's can be stacked
- . . .
- Restart phases 1, 1.5, and 2, but do not continue to phase 3
- . . .
- Phase 2 tasks are altered a bit
- . . .
- The CALL is aborted without error if any of the following are detected
- Newly appearing unquoted, unescaped & or |
- The resultant command token begins with unquoted, unescaped (
- The very first token after the removed CALL begins with @
- . . .
There are other Phase 6 peculiarities that I omitted above. Read the StackOverflow post for more info.
Dave Benham