Why is the syntax for touching a file from the command prompt so strange?
COPY /B FILE+,,
What strange syntax!
What’s with the plus sign and the commas, anyway?
The formal syntax is the much more straightforward
COPY /B A+B+C+D
This means to start with the file
then append the files
treating them all as binary files.
If you omit the
then you get
COPY /B A+
“Start with A, then append nothing.”
The side effect is that the last-write time gets updated,
because the command processor opens
A for append,
then closes the handle.
That syntax has worked since at least MS-DOS 2.1
(the earliest version I still have a virtual machine for).
I dont know where the two-comma version came from,
but it most likely exploited a parsing glitch in
and somehow this variant gained traction and
became the version everybody used
(even though the other version is two keystrokes shorter).
As a result, this weird syntax has become grandfathered
as a special-case in the
Here’s some actual code from the part of
CMD.EXE which parses the arguments to the
if (parse_state == SEEN_TWO_COMMAS) copy_mode = TOUCH;