MS-DOS 6.22 Batch File GOTO Label Limits
In MS-DOS 6.22, batch file labels targeted by the GOTO
command are subject to strict syntax, length, and parsing constraints
defined by the 16-bit COMMAND.COM interpreter. Writing
reliable scripts requires understanding these boundaries, which include
an eight-character truncation limit, delimiter behavior, case
insensitivity, and the handling of reserved shell characters.
The Eight-Character Truncation Limit
The most critical constraint in MS-DOS 6.22 is that the
COMMAND.COM interpreter only evaluates the first eight
characters of a label name. While you can write a label longer than
eight characters, any character beyond the eighth is completely ignored
during label resolution.
For example, the interpreter views the following two labels as identical:
:PROCESS_FILE_A:PROCESS_FILE_B
Because both start with :PROCESS_, a command such as
GOTO PROCESS_FILE_B will jump to whichever label appears
first in the file, resulting in unintended logic loops or execution
errors. To ensure proper branching, every label must be uniquely
identifiable within its first eight characters.
Case Insensitivity
MS-DOS 6.22 treats all label names as case-insensitive. A label
defined as :MyLabel can be called interchangeably using
GOTO MYLABEL, GOTO mylabel, or
GOTO MyLabel. Internal conversion standardizes the
characters during lookup.
Spaces and Delimiters
Label definitions cannot contain spaces or standard DOS command delimiters. The characters treated as delimiters include:
- Space (
) - Horizontal tab
- Comma (
,) - Semicolon (
;) - Equal sign (
=)
When COMMAND.COM encounters any of these characters
after the colon, it interprets the delimiter as the end of the label
name. Any text following the delimiter is ignored during definition. For
example, :STEP 1 will be interpreted solely as the label
:STEP.
Reserved Shell Characters
You cannot use redirection and piping symbols inside a label name. Including the following characters will trigger immediate syntax errors or unexpected file operations:
<(Input redirection)>(Output redirection)|(Pipe)
Colon Usage and Pseudo-Labels
In MS-DOS 6.22, a label definition must begin with a single colon at
the very start of the line (e.g., :START). However, the
GOTO command syntax requires omitting the colon (e.g.,
GOTO START). Unlike modern Windows NT command processors,
typing GOTO :START in MS-DOS 6.22 will result in a "Label
not found" error.
Additionally, lines beginning with double colons (::)
are commonly used as comment lines in MS-DOS. You cannot target a
double-colon comment line with a GOTO command, as
COMMAND.COM treats the second colon as an invalid label
character and will fail to resolve the jump.