19

MS DOS and derived systems use backslash \ for path separator and slash '/' for command parameters. Unix and a number of other systems used slash '/' for paths and backslash \ for escaping special characters. And to this day this discrepancy causes countless woes to people working on cross-compilers, cross-platform tools, things that have to take network paths or URLs as well as file paths, and other stuff that you'd never imagine to suffer from this.

Why? What are the origins of this difference? Who's to blame and what's their excuse?

19

PC/MS-DOS 1 used the slash (/) as the command line switch indicator (like DEC's RSX11 and DG's RTOS before), so when DOS 2.0 introduced subdirectories, they did need a new one. Backslash (\) came somewhat natural - at least on US keyboards.


With 2.0 IBM/Microsoft also tried to reverse that decision and introduce a syscall (INT 21h function 3700h and 3701h) and a CONFIG.SYS option (SWITCHAR=) to set a different switch indicator. All manufacturer supplied commands would obey that new char. Set to a hyphen (-) would make the syntax more like Unix.

In fact, in paths, the OS didn't care. All dedicated path names, like in syscalls, can be written with either slash. It's only within the command line scan of each command, that simple slashes get interpreted as switch indicators. The idea was that people could/should migrate to a Unix-like style, but that didn't catch on.

With DOS 3.0 the SWITCHAR= option got removed fom CONFIG.SYS, but the syscalls are still availabe up to today.

  • 4
    Re the SWITCHAR syscalls, DOS 4 ignored them, and from DOS 5 onwards / is hard-coded (so the syscall still works, but it always returns /). There are several TSRs which restore functioning syscalls, and alternative command processors which honour them (e.g. 4DOS, IIRC). The use of / was indeed based on the DEC operating systems (at least, that’s what The MS-DOS Encyclopedia says). – Stephen Kitt Sep 9 '17 at 13:28
  • I always assumed that the origin of MSDOS use of / for switches was because the origin of MSDOS was SCP's 86-DOS aka QDOS, that Microsoft bought from SCP to create PCDOS for IBM. Because SCP created QDOS as a 8086 "clone" of CP/M and CP/M used / as the switch character (and it was modeled after DEC operating systems). So the indirect origin is DEC with CP/M in between... – mannaggia Sep 9 '17 at 21:12
  • 1
    @Raffzahn wow my memory of CP/M is not as good as I thought... though I used it in school at the same time as RSTS/E and DCL and I guess it's all merged... – mannaggia Sep 10 '17 at 1:58
  • 1
    @mannaggia - I also have memories of CP/M that disagree here. But I think what's happening here is that after official CP/M-80 development stagnated, 3rd party add-ons may have extended or replaced the shell with more DOS-like versions. This summary of CP/M 3 commands dates from 1984, but the era I was using CP/M in was closer to 1988, and it may well have been a substantially different dialect by then. – Jules Sep 10 '17 at 4:22
  • 1
    Just because, here's Larry Osterman of Microsoft's recollections on the issue which are congruent with yours. (Looks like his blog post's title got munged through various blogging platform transitions.) – Dranon Sep 11 '17 at 2:22
4

The README.txt file in the MS-DOS 2.0 source code, which was apparently intended to guide OEMs on how to build custom DOS builds for their hardware, indicates that the decision to use backslash was requested by IBM: Microsoft had been originally intending to use forward slash, and the change happened late in the development process. This is probably why the kernel ended up supporting the use of either character -- it was, presumably, too late to change over fully.

The user manual contains some significant errors. Most of these are due to last minute changes to achieve a greater degree of compatibility with IBM's implementation of MS-DOS (PC DOS). This includes the use of "\" instead of "/" as the path separator, and "/" instead of "-" as the switch character.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.