I came across a mind-blowing weird script that crashes the console:
set "h=/?" & call [if | for | rem] %%h%%
IF
,FOR
andREM
aren't normal internal commands. They use an own special parser, which possibly caused some interception errors so it crashed.
@jeb pointed out CALL
doesn't execute the following special characters, but instead convert them into a "token" (version dependent):
&
returns/
&&
returns1
|
returns2
||
returns0
/?
returns<
@
returns+
@()
returns;
@if a==a :
returns,
@for %a in () do :
returns+
@rem :
returns-
However, even though they have unique parsers, it still doesn't explain why they all crash. So I did some testing:
- Remove
call
C:\>set "h=/?" & for %h% %%h%% was unexpected at this time.
- Change the command to something else. (I tried all other internal commands, none works)
- Seperate two commands:
C:\>set "h=/?" C:\>call for %%h%% --FOR help message--
- Add
@
C:\>set "h=/?" & call for @%%h%% CRASH!!!
- Surround the scriptblock by
()
C:\>set "h=/?" & call for (%%h%%) CRASH!!!
Summary of question:
- What role does
call
play? - What caused the parser to crash?