Why is the DOS path character ""?
Many, many months ago, Declan Eardly asked why the \ character was chosen as the path separator.
The answer's from before my time, but I do remember the original reasons.
It all stems from Microsoft's relationship with IBM. For DOS 1.0, DOS only supported floppy disks.
Many of the DOS utilities (except for command.com) were written by IBM, and they used the "/" character as the "switch" character for their utilities (the "switch" character is the character that's used to distinguish command line switches - on *nix, it's the "-" character, on most DEC operating systems (including VMS, the DECSystem-20 and DECSystem-10), it's the "/" character" (note: I'm grey on whether the "/" character came from IBM or from Microsoft - several of the original MS-DOS developers were old-hand DEC-20 developers, so it's possible that they carried it forward from their DEC background).
The fact that the "/" character conflicted with the path character of another relatively popular operating system wasn't particularly relevant to the original developers - after all, DOS didn't support directories, just files in a single root directory.
Then along came DOS 2.0. DOS 2.0 was tied to the PC/XT, whose major feature was a 10M hard disk. IBM asked the Microsoft to add support for hard disks, and the MS-DOS developers took this as an opportunity to add support for modern file APIs - they added a whole series of handle based APIs to the system (DOS 1.0 relied on an application controlled structure called an FCB). They also had to add support for hierarchical paths.
Now historically there have been a number of different mechanisms for providing hierarchical paths. The DecSystem-20, for example represented directories as: "<volume>:"<"<Directory>[.<Subdirectory>">"FileName.Extension[,Version]" ("PS:<SYSTEM>MONITR.EXE,4"). VMS used a similar naming scheme, but instead of < and > characters it used [ and ] (and VMS used ";" to differentiate between versions of files). *nix defines hierarchical paths with a simple hierarchy rooted at "/" - in *nix's naming hierarchy, there's no way of differentiating between files and directories, etc (this isn't bad, btw, it just is).
For MS-DOS 2.0, the designers of DOS chose a hybrid version - they already had support for drive letters from DOS 1.0, so they needed to continue using that. And they chose to use the *nix style method of specifying a hierarchy - instead of calling the directory out in the filename (like VMS and the DEC-20), they simply made the directory and filename indistinguishable parts of the path.
But there was a problem. They couldn't use the *nix form of path separator of "/", because the "/" was being used for the switch character.
So what were they to do? They could have used the "." character like the DEC machines, but the "." character was being used to differentiate between file and extension. So they chose the next best thing - the "\" character, which was visually similar to the "/" character.
And that's how the "\" character was chosen.
Here's a little known secret about MS-DOS. The DOS developers weren't particularly happy about this state of affairs - heck, they all used Xenix machines for email and stuff, so they were familiar with the *nix command semantics. So they coded the OS to accept either "/" or "\" character as the path character (this continues today, btw - try typing "notepad c:/boot.ini" on an XP machine (if you're an admin)). And they went one step further. They added an undocumented system call to change the switch character. And updated the utilities to respect this flag.
And then they went and finished out the scenario: They added a config.sys option, SWITCHAR= that would let you set the switch character to "-".
Which flipped MS-DOS into a *nix style system where command lines used "-switch", and paths were / delimited.
I don't know the fate of the switchar API, it's been long gone for many years now.
So that's why the path character is "\". It's because "/" was taken.
Edit: Fixed title - it's been bugging me all week.
Comments
Anonymous
June 24, 2005
The comment has been removedAnonymous
June 24, 2005
Interesting, I had always wondered why DOS used something different wen UNIX was well established and accepted standard and I sometimes wondered if it was different just for the sake of being different.
Glad to see that assumption was wrong.Anonymous
June 24, 2005
The comment has been removedAnonymous
June 24, 2005
Just wondering about a little detail here:
"For MS-DOS 2.0, the designers of DOS chose a hybrid version - they already had support for drive letters from DOS 1.0, so they needed to continue using that."
Where did the drive letters come from, then? I really hate them :) Happily I can, and do, use junctions points now, but you still need to have at least one left. It's so much cleaner with the unified filesystem :) And it is easier to discover special files like the CON, NUL, LPT devices when you can just do
dir /devices or something like that.Anonymous
June 24, 2005
The comment has been removedAnonymous
June 24, 2005
I don't understand why the switch/parameter character cannot be present in paths. Unix has no problems working with paths that have - in them, most systems, including Windows, can handle paths with spaces in them even though spaces are used to separate arguments and so on.Anonymous
June 24, 2005
Andreas: *nix commands have no problems with files with "-" in the name?
How do you remove the file named "-r"?Anonymous
June 24, 2005
The comment has been removedAnonymous
June 24, 2005
> How do you remove the file named "-r"?
With "rm -- -r" of course. There's actually quite a few ways to do this.Anonymous
June 24, 2005
The comment has been removedAnonymous
June 24, 2005
I wish it was possible to have a directory junction pointing at a drive letter for a mounted UNC path. That's the only thing that escapes my amazing single filesystem: I have some stuff that lives on another computer, and there's no way to map L:My Documents to C:My Documents were L: is a mounted path. It works fine otherwise.
Why is this the case anyway? Why are mounted UNC paths any different?Anonymous
June 24, 2005
I'm way too young know this first-hand, so I'll ask.
Why is there a "" key on the keyboard in the first place? As far as I know, they aren't used in English grammar, and to this day, most common users don't know which is "back" and which is "forward."
I suppose I can ask the same about "{" and "}", but I don't mind those as much.
Since DOS and Windows handle "/" as well as "", it'd be nice if it would switch to using "/" by default, since Internet URLs use forward slashes, and most people are familiar with them (even though browsers/web servers have to support "" as well, because of the problem I mentioned earlier, which ultimately lead to security bugs in server-side web software).
I can't imagine switching to "/" would hurt much backwards compatability, since most path paramters have to be put in quotes these days (thanks to the needlessly long "Document and Settings" and "Program Files").
I too would like to get rid of drive letters. I'm consdering mounting my all-in-one memory-card reader onto a folder on my hard drive because I'm tired of having C:, D:, E:, F:, G:, H:, I:, J: all show up under My Computer (and X:, Y:, and Z:, but that was my doing). If I mount everything, I can pretend that C: stands for "Computer," but I suspect mounting CD-ROMs causes problems for some pesky copy-protected games (which are another pet peeve of mine).
I was hoping Monad would help reduce the visibility of drive letters, but I was wrong. It doesn't even support changing the current path to a UNC share, which is a HUGE limitation of both CMD.EXE and any future shells.Anonymous
June 24, 2005
> Why is there a "" key on the keyboard in the first place? As far as I know, they aren't used in English grammar, and to this day, most common users don't know which is "back" and which is "forward."
The backslash was invented by Bob Bemer http://www.thocp.net/biographies/bemer_bob.htm
It's use was so you could make the / and / symbols (AND and OR if you've ever done boolean logic) in the ALGOL language.Anonymous
June 24, 2005
And of course I meant "its" not "it's". As is oft requested, I wish the msdn blogs had a preview button.Anonymous
June 24, 2005
The comment has been removedAnonymous
June 25, 2005
The comment has been removedAnonymous
June 26, 2005
Crikey - I'd almost forgotten I'd asked that ... 8)
many thanks for the explanation - this was one of those little things that I have wondered about every now and then - and it is very nice to have an answer (and a pretty comprehensive one to boot).
This has made my day!
Declan EardlyAnonymous
June 26, 2005
Another 'undocumented feature' in MS-DOS that I used a lot was that the API calls that used drive letters did not validate the character for a drive letter - this let you use things like "#:/HIDDEN" and get away with it...although I am now hazy about what actually happened, I remember that I used it several times.Anonymous
June 27, 2005
The comment has been removedAnonymous
June 27, 2005
I remember being very annoyed when I went from using Visual C++ 1.52 to a 5.0 (both on Windows NT 4). 1.52, being 16-bit, used the 16-bit file dialogs, which could grok a typed path containing forward slashes. 5.0 used Explorer file dialogs which couldn't (I don't know if this has been fixed in later Windowses).
Do we get a matching retrospective on the function that moved all the special files into DEV (sorry, /DEV)?Anonymous
June 29, 2005
"It doesn't even support changing the current path to a UNC share, which is a HUGE limitation of both CMD.EXE and any future shells."
4NT (from http://jpsoft.com/) supports CD to a UNC path. Just type CDD \myservermyshare and there you are... At the root of a share! :)
(I even suspect it was I who suggested this to JPSoft many years ago)
--
RuneAnonymous
June 29, 2005
HtmlEncoding fixed? Looks OK in the comment posting form... let's see how it looks once it's posted...Anonymous
July 21, 2005
This is interesting bit of information.Anonymous
January 13, 2007
Ancient History: The origins of ''Anonymous
February 11, 2007
Explicación (en ingles) de por qué se elegió el caracter (backslash) como el separador de ruta para Windows.Anonymous
February 11, 2007
PingBack from http://warpedvisions.org/2007/02/11/why-is-the-dos-path-character/Anonymous
February 11, 2007
Larry Osterman tells the entire story: simply because slashes were already used for parameters before DOS even knew what a path or a directory is. Nice read and a trip down memory lane.Anonymous
May 13, 2008
PingBack from http://gen5.info/q/2008/05/13/tame-sql-with-multiline-quotes-in-c-and-php/Anonymous
January 08, 2009
PingBack from http://billgatos.wordpress.com/2007/02/22/la-barra-inversa-de-ms-dos/Anonymous
January 18, 2009
PingBack from http://www.keyongtech.com/4605205-using-inquire-to-test-ifAnonymous
January 20, 2009
PingBack from http://www.hilpers.com/101047-stimmt-es-dass-in-firefox/5Anonymous
February 25, 2009
PingBack from http://mt.i3o.de/2009/02/geklaert-warum-wird-unter-dos-und-windows-anstatt-verwendet/Anonymous
February 26, 2009
PingBack from http://www.7c0h.com.ar/blog/?p=395Anonymous
February 26, 2009
PingBack from http://emend.appspot.com/sites/blogs.msdn.com/edits/0Anonymous
February 26, 2009
submitted by scientologist2 to programming [link] [368 comments]Anonymous
February 26, 2009
PingBack from http://mexisoft.net/blog/2009/02/26/larry-ostermans-weblog-why-is-the-dos-path-character/Anonymous
February 26, 2009
PingBack from http://rapd.wordpress.com/2009/02/26/why-dos-path-seperator-is-backslash/Anonymous
February 26, 2009
PingBack from http://greencrab.wordpress.com/2009/02/26/links-for-2009-02-26/Anonymous
February 26, 2009
PingBack from http://www.soliva.org/?p=858Anonymous
February 26, 2009
PingBack from http://pateandopiedras.com/buzzeando/?p=1220Anonymous
February 27, 2009
PingBack from http://www.feedxtractor.com/la-curiosa-historia-de-porque-es-el-separador-de-directorios-en-el-dos/Anonymous
February 27, 2009
PingBack from http://www.macrohw.com/blog/?p=2022Anonymous
February 27, 2009
PingBack from http://turulcsirip.hu/perma/1258471568Anonymous
February 27, 2009
PingBack from http://www.acervus.ca/2009/02/27/links-for-2009-02-27/Anonymous
February 27, 2009
PingBack from http://www.algoestapasando.com/la-curiosa-historia-de-porque-es-el-separador-de-directorios-en-el-dos/Anonymous
February 28, 2009
PingBack from http://www.franciscoespino.es/wordpress/textos/el-origen-del-mal/Anonymous
March 01, 2009
The comment has been removedAnonymous
March 01, 2009
PingBack from http://almosteffortless.com/2009/03/01/weekly-digest-3-1-09/Anonymous
March 04, 2009
PingBack from http://hektik.org/forums/main-page/4470-weekly-dub-www.html#post18389Anonymous
March 08, 2009
PingBack from http://www.mentedigitale.org/news/2009/03/08/perche-dos-usa-la-barra-e-invece-unix/Anonymous
March 09, 2009
PingBack from http://megos.wordpress.com/2009/03/10/die-geschichte-vom-backslash/Anonymous
May 31, 2009
PingBack from http://woodtvstand.info/story.php?id=1442Anonymous
June 08, 2009
PingBack from http://toenailfungusite.info/story.php?id=4113Anonymous
June 15, 2009
PingBack from http://mydebtconsolidator.info/story.php?id=20153