A
Al Dunbar [MS-MVP]
First, I'm not sure if this is a problem for all flavours of NT, but I have
just encountered it on XP (SP1 and SP2), and thought I would put it out
there for comment.
I have been in occasional discussion on the somewhat undocumented/incidental
use of ":::" as an alternative to "REM" for including comments in batch
script code. To my knowledge this has never caused me grief before, and I
have argued for its use as more obviously a non-executable statement.
I at first thought it must be some weird combination of delayedexpansion and
conditional blocks of code. Further testing indicates it is much more basic
than that.
Note the two cases below. Although extremely simple and virtually identical,
the first works as one would expect, displaying the following output:
testing 1
testing 2
while the second one displays only "The syntax of the command is incorrect."
1) good one:
@echo off
(
::: test
echo testing 1
)
echo testing 3
2) bad one:
@echo off
(
::: test
echo testing 1
)
echo testing 2
The only difference is the extra blank line between the ":::" comment and
the following ECHO statement.
In retrospect, I typically precede each block of code with a ":::" comment
with no intervening blank line, however, recently had the fortune (good or
bad) to opt for a bit of whitespace. This likely explains why it took so
long to get bitten by this one.
Is this a known issue? If so, I am surprised that it had not come up in the
various mentions of this form of commenting in the newsgroups. Is it perhaps
related to some other syntactical issue whose effects are more clearly
obvious?
Other than that, all I can think of to ask is: any comment?
/Al
just encountered it on XP (SP1 and SP2), and thought I would put it out
there for comment.
I have been in occasional discussion on the somewhat undocumented/incidental
use of ":::" as an alternative to "REM" for including comments in batch
script code. To my knowledge this has never caused me grief before, and I
have argued for its use as more obviously a non-executable statement.
I at first thought it must be some weird combination of delayedexpansion and
conditional blocks of code. Further testing indicates it is much more basic
than that.
Note the two cases below. Although extremely simple and virtually identical,
the first works as one would expect, displaying the following output:
testing 1
testing 2
while the second one displays only "The syntax of the command is incorrect."
1) good one:
@echo off
(
::: test
echo testing 1
)
echo testing 3
2) bad one:
@echo off
(
::: test
echo testing 1
)
echo testing 2
The only difference is the extra blank line between the ":::" comment and
the following ECHO statement.
In retrospect, I typically precede each block of code with a ":::" comment
with no intervening blank line, however, recently had the fortune (good or
bad) to opt for a bit of whitespace. This likely explains why it took so
long to get bitten by this one.
Is this a known issue? If so, I am surprised that it had not come up in the
various mentions of this form of commenting in the newsgroups. Is it perhaps
related to some other syntactical issue whose effects are more clearly
obvious?
Other than that, all I can think of to ask is: any comment?
/Al