Call bug using silent operator @

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Call bug using silent operator @

#1 Post by carlos » 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 @.

For example:

Code: Select all

@call vol
Is different than:

Code: Select all

call @vol
The later not execute the command.

This can be used as another way of write a single line comment

Code: Select all

call @ Single line comment

IcarusLives
Posts: 161
Joined: 17 Jan 2016 23:55

Re: Call bug using silent operator @

#2 Post by IcarusLives » 16 Aug 2019 12:51

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 . . .

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Call bug using silent operator @

#3 Post by dbenham » 16 Aug 2019 13:54

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

Post Reply