You are not logged in.

#1 14 Jan 2016 04:36

dbenham
Member
From: U.S. east coast
Registered: 15 Apr 2012
Posts: 111

Minor flaw in REM documentation

At http://ss64.com/nt/rem.html, near the bottom, you state:

Bugs

In Windows 2000 and XP a comment like
::%~
or
REM %~ will be interpreted giving the error:
The following usage of the path operator in batch-parameter substitution is invalid: %~

It should be noted that the error is fatal - all batch processing terminates when a REM like that "executes".
A similar fatal error also occurs if variable var is defined and you create a remark like the following:

rem %var:=

or

rem %var:*=

The problem is not limited to XP or Windows 2000.

I would classify the problem more as a design flaw than a bug, and it is an issue for all modern Windows versions that use CMD.EXE.

It is a result of the batch parsing rules used by CMD.EXE that jeb outlines at http://stackoverflow.com/a/4095133/1012053, coupled with the detailed % expansion rules that I outline at http://stackoverflow.com/a/7970912/1012053. In the Note 1 of that post, I discuss how REM is susceptible to the fatal error that can arise from invalid percent expansion.


Dave Benham

Last edited by dbenham (14 Jan 2016 04:55)

Offline

#2 14 Jan 2016 14:27

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: Minor flaw in REM documentation

^ Thanks, I'll update this page over the weekend when I get time.

Offline

Board footer

Powered by