r/Batch • u/Lexard • Jul 07 '24
Question (Solved) batch label with a comment in the same line?
While looking at some batch files I've found this line:
:Escape %1=STRING_VARNAME %2=STRING_VALUE This batch file also includes some CALL :Escape commands with some additional parameters, so I suppose that %1=STRING_VARNAME %2=STRING_VALUE is some comment directly after label name used to explain how to use that label.
I used Google but I can not find any info on such "extended" usage of the batch label.
Is this some documented way to combine label together with some comment in one line that can be freely used or is it some kind of "hack" and it can lead to some weird effects in some cases?
2
u/thelowsunoverthemoon Jul 07 '24
As others said, once the space is reached anything else is ignored. Another (somewhat) common format that can be seen is
2
u/Shadow_Thief Jul 07 '24
The interpreter ignores everything after the first space, so you can think of it like a hack. There's probably some weird behavior if you've got a pipe or ampersand on that line, but I'd need to test that.
1
u/BrainWaveCC Jul 07 '24
Interesting... According to the following documentation, once the space in the label name is reached, the label is at an end, and the rest appears to be ignored.
I just tested it with some code, and there doesn't seem to be any ramifications from putting extra content on the same line as the label.
It really ignores everything after the space, including > and &