Why does the Windows Ecosystem use /x for command line args rather than -x like everyone else?

The / thing is a serious case of legacy compat gone nuts. And it happens when you have an ecosystem and you need to keep things working in that ecosystem even as it evolves.

So, we have to go ALL the way back to CP/M an operating system most of you won’t ever have heard of but it was popular on a variety of devices in the late 70s and even into the early 80s.

CP/M has no directories, it’s for floppies, small ones at that. Well actually small in capacity, but they were usually the 8” huge floppies you may have seen at a museum. Anyway since foo/bar isn’t necessary if you have no directories, they used / for the command line option on tools like “dir”.

OK so far?

Along comes the PC, it runs DOS and CP/M. DOS was supposed to be the bargoon thing and CP/M for the serious people. It didn’t work out that way. DOS gets wildly popular. But to make things easy for people, DOS had adopted the / as the command line switch character. Just to be a little bit more like CP/M so some of the basic commands are the same. So you don’t go totally insane going from one to the other.

So CP/M basically dies. DOS becomes the major OS of the early 80s. It’s barely an OS, it’s more like an ambitious executive. But anyway. DOS gets big. Then hard-drives become a thing on the PC/XT and we want directories but oops, the / character is already used for switches on like every important command. So… no problem we’ll use backslash. So c:\foo\bar is born.

Windows had to be compatible with DOS because DOS was under the hood for ages. And even if it wasn’t by then everyone in that ecosystem was using \ in their programs. So if they had switched to / everything would have broken.

Windows95 gets a whole new file system but they can’t fix it then either. Nor can OS/2 or Windows NT all of which had to be compatible with existing programs or nobody would buy them.

So the only place you don’t see / for switches and \ for path is in the linux subsystem. Interestingly the underlying file system doesn’t care…

And it’s all because DOS decided to look like CP/M rather than Unix. But can you blame them? There were probably 100ish Unix installations at the time they made this call and considerably more CP/M users… Oh well.

I’m a software engineer at Facebook; I specialize in software performance engineering and programming tools generally. I survived Microsoft from 1988 to 2017.