The caret serves as the continuation character for batch files

We saw earlier that the caret is the escape character for the batch language. In a comment to that article, KJK::Hyperion mentioned that the caret serves as the line continuation character. A useful tip if you still find yourself messing with batch files. Mark Yocum elaborates on this point a bit more.

Comments (12)
  1. I use this ^

       all ^

       the ^


    Of course, I have to deal with batch scripts that call binaries with huge numbers of arguments (I’m looking at you, wttcl.exe)

    Wish list: allow a blank line to terminate the chain (putting a caret on the last of the command allows for easy copy/paste/add/delete arguments; much like allowing a comma after the last element of an array in C.)

  2. Mantas says:

    kewl! I kinda hoped cmd.exe would have something like that.

    Now if only there was a way to use a variable as a name for another variable… If I enable delayedexpansion, !foo_%bar%! works, but then if I do "echo Error!", it only prints "Error"…

  3. Bryan Price says:

    And I didn’t think there was much you could really teach me in the vagaries of batch.  That certainly is a new one on me.


  4. Nick says:


    I’ve always viewed Batch as a language that no one man can ever fully understand. There will always be some quirk, some parser exploit-become-feature, or some trick that creates a whole new way of doing things.

    Much like the universe, if anyone ever does fully come to understand Batch then the language will instantly be replaced by an infinitely weirder and more complex version of itself. This has obviously happened at least once before ;)

  5. Miral says:

    At least twice before.  First there was Command Extensions.  Now there is PowerShell.  :)  (Quibblers might include WSH in there too.)

  6. Roger says:

    It is remarkable what the choice of the forward slash for switches in CP/M-80 has caused!

    Because of that, MS-DOS used backslashes in pathnames.

    Then because of that, backslashes can’t be used for continuations in batch files.

  7. John Elliott says:

    @Roger: The "/" wasn’t used as an option character by CP/M or the programs supplied with it. It was used by Microsoft’s programming languages for CP/M, but I don’t know where they got the idea.

  8. 640k says:

    Maybe from "CPforward slashM".

  9. Peter says:


    Batch files predate directory hierarchies.  

    Thanks to Google Books, I find Operating Systems by William Stalling.  Page 80 says:

    "…Microsoft developed DOS 2.0, released in 1983.  It contained support for the hard disk and provided for hierarchical directories.  Heretofore, a disk could contain only one directory of files, supporting a maximum of 64 files."

    DEC lines of computers tended to have "/" as the switch character.  Directories were described (roughly) as DISK:[DIR.SUBDIR]FILE.EXE with appropriate defaults to make like simple.  The first BASIC that Gates wrote was on a DEC machine, so he may have already had a fondness for / as a switch character.

  10. Michael says:


    DEC lines of computers tended to have "/" as the switch character.

    DCL ( also allowed (required? I forget) you to omit a space between a command and its slash-delimited options.  Hence "CREATE" created a regular file, while "CREATE/DIRECTORY" created a directory.  I suspect that was the inspiration for the similar feature of DOS built-in commands, wherein "dir /w" and "dir/w" are equivalent.

  11. Daev says:

    The reason so many microcomputer operating systems used DEC syntax was that DEC was the most successful and respected maker of minicomputer operating systems.  In the late 70s and early 80s, TOPS and VMS set the standard that everyone else copied.  It wasn’t just Bill Gates — OS designers who’d never used a Digital machine kept copies of the TOPS manuals on hand to provide guidance.

    Whenever discussions of Microsoft’s design choices come up nowadays, there’s often this implicit assumption that Unix ruled the world and those micro weirdos flagrantly disregarded the "standard" use of backslash, signals, newlines, etc.  Not true — instead, Unix was considered a bizarre niche product.  Hard to use, easy to port (if you didn’t care about the details), quick to crash, and promising amazing power to those willing to grok its low-level mysteries: in short, Unix was FORTH.

    It’s only because C and shell scripting included so many Unix-specific assumptions ("n denotes the end-of-line character," etc.), and they spawned so many modern programming languages from Java to Perl, that people have come to imagine that these things are so ubiquitous they must be eternal computer science principles.

    So that’s why I really like articles about the batch file language.  Cryptic and crippled it may be, but it reflects a true parallel stream of evolution that never copied from Unix.  Powershell is great, but it sure looks like it’s picked up on the Unix assumptions for everything from environment variables to option syntax.  Unlike Kildall and Gates, Powershell’s authors weren’t running to the DEC Command Language to settle design issues.

  12. David Moisan says:


    Jeffrey Snover has cited VMS DCL as an inspiration for PowerShell;  PS owes more to it than to any Unix shell.

    I’m 45 and have been in IT since IBM was the "evil empire" and it is hard if not impossible to overstate Digital’s influence on the computer world.  That’s something the average twentysomething Linux bigot will never realize.

    Also remember that MS *did* hire Dave Cutler.

Comments are closed.