
Why is the DOS path character "\"? - thibaut_barrere
http://blogs.msdn.com/b/larryosterman/archive/2005/06/24/432386.aspx
======
jgrahamc
Goes deeper than just IBM. Prior to DOS there was CP/M and CP/M had many
programs with an older heritage. For example, it was possible to copy from a
source (such as a file) to a destination (such as another file, or an I/O
port) using a program called PIP
(<http://en.wikipedia.org/wiki/Peripheral_Interchange_Program>). On CP/M, for
example, you could print a file with the command (PRN: is the name of the
printer device; at the time that was likely a parallel connected printer):

    
    
        PIP PRN:=FOO.TXT
    

PIP itself predates CP/M having been present on machines such as the PDP-11.
Wikipedia tells me that it was first implemented on the PDP-6. For example, on
the PDP-10 you could do:

    
    
        PIP DTA1:/X=DSK:*.*
    

which copied all the files from the disk onto tape. The /X there modifies the
destination and indicates that file attributes (modification time etc.) should
be preserved.

PS Now my memory is fully restored from 1980s backing store I believe that
CP/M actually replaced the / in PIP with single character switches inside []
and that the route to / being switches in MS-DOS most likely comes through DEC
heritage from the PDP series. For example, the W switches would ignore r/o set
on a file and overwrite it. This would copy all .COM files (i.e. executables)
from B: to A: and overwrite without warning:

    
    
        PIP A:=B:*.COM[W]

~~~
yread
You could still do that with copy in MS-DOS, I have a feeling my mom still
does it since she has a printer on parallel port. So if she wants to print a
textfile it's just

    
    
         copy file.txt LPT1
    

she can also print multiple files or results of print to file using the /b
switch (binary) ignoring EOF

That also explains why you shouldn't use LPT1 as file name - it was a special
name that meant first parallel port. I remember seeing a ridiculing thread
about it on HN some time ago

~~~
rhizome
I'm pretty sure you could still do this up until at least Win2k+ if your
mapped printer had a port associated.

~~~
Natsu
It still works on Windows 7. Sadly, I know that offhand due to having to deal
with some weird legacy stuff from our corporate HQ.

------
po
Interestingly, if you ever come to Japan you will find many people expect path
separators to be yen symbols (¥). Their windows paths look like:

¥docs¥finance¥

To understand the reason, just check out the table on the Shift-JIS encoding:

<http://en.wikipedia.org/wiki/Shift_JIS>

Specifically, look at the character at 0x5C where the backslash sits in ASCII.
Learning this was one of those mind-blowing moments when you try to imagine
what a world where that was normal would be like.

~~~
rangibaby
Interesting! I wonder why they changed that particular character and not one
that is literally _everywhere_ in DOS.

Using ¥ as backslash still works in Windows and legacy apps (in OSX option+¥
gives a "real" \\.)

This leads to some interesting situations: Word documents filled with ¥ where
there should be \ and vice versa. By interesting I mean extremely annoying.

Another caveat is that anything hardcoded to use the tilde ~ will probably
break because it is mapped to a completely key on Japanese keyboards. This
causes endless fun in DOSBOX or even newer games: to get the console in Doom 3
I had to edit the source and recompile it with the console key mapped to
another character.

~~~
tangus
Several positions in the table ({ | } [ \ ] @) were meant for "national
variants". I guess those characters were deemed unimportant at the time.

Here is some more info: <http://www.cs.tut.fi/~jkorpela/chars.html#national-
ascii>

~~~
po
_Thus, the characters that appear in those positions - including those in US-
ASCII - are somewhat "unsafe" in international data transfer_

...

 _Systems that support ISO Latin 1 in principle may still reflect the use of
national variants of ASCII in some details; for example, an ASCII character
might get printed or displayed according to some national variant. Thus, even
"plain ASCII text" is thereby not always portable from one system or
application to another._

That's awesome! Hard to believe that systems have worked as well as they have.
It's pretty obvious nobody was expecting that one day all computers would have
to read each other's data pretty much constantly.

So I guess the question is: why did the DOS developers pick the character that
happens to vary from region to region? I guess they didn't know?

~~~
rangibaby
As a wild guess, I would say that in the days before the internet made
"international data transfer" something a regular person would encounter
frequently, the thought just never occurred to them.

------
greggman
I've always felt the better question is "Why is the UNIX path character "/"?

People use "/" as a date separator as in 12/25/1979 so effectively banning
that character as a character in filenames seems a really poor choices. By
that metric chosing "\" is a much better choice because "\" is used no where I
know outside of computers. I've never encountered it anywhere outside of
computers so arguable it's the perfect choice for a path character.

~~~
darklajid
Other people use '.' in dates. Or '-'. Especially the latter would end up with
the same problem: Why is - and -- used as a switch character if it is used in
dates (and even quite common in normal text, names)?

And given that the history of '\' as a path separator is that long, maybe you
haven't seen in elsewhere _because_ it is now forever taken for the world's
most popular OS?

~~~
celoyd
_Why is - and -- used as a switch character if it is used in dates (and even
quite common in normal text, names)_

Those uses rarely have it next to whitespace, and almost never immediately
after whitespace.

If someone’s named Jean-Claude, it is not customary to refer to them as
-Claude for short, and if I refer to items dated 2012-03-19 and 2012-03-20, it
is not customary to call one of them -20.

But that last example shows something that Unixy switches do conflict with:
negative numbers.

~~~
darklajid
Well responded.

Two (not entirely serious) counterarguments:

\- Lists like this

\- Abusing the char as em-dash

\- Weird languages. In German it's quite common to use that character to
shorten the monster words. Pulling samples from my reared (note the disclaimer
about being not to serious)

    
    
      Lebens- und Krankenversicherung
      (Shorthand for Lebensversicherung und Krankenversicherung) 
    

The inverse is possible, but less common as far as I am aware

    
    
      Arbeitsplatz und -Umfeld
      (Arbeitsplatz und Arbeitsumfeld?) 
    

Looks ugly to me and the samples are pre-coffee, but this is definitely
possible.

~~~
celoyd
All good points. I would say that lists like that are also abuse; the hyphens
there ought to be · or something similar. But it certainly appears in the
wild. (Similarly, in formal contexts, the negative sign is − and not -, but
very few people care.)

The last usage is also possible in English. A construction like “face-huggers
and -eaters” is rare but not outlandish.

------
PaulHoule
The early DOS developers wanted to use "/", so it turns out the underlying OS
will accept either / or \\. The main trouble you have is that cmd.exe and
powershell think \ is the switch character -- so as long as you're not writing
programs that write shell scripts or shell out you do OK.

Back when I was a Windows dev I drove the guys I worked with nuts because I
used "/" instead of "\", figuring it would be more portable and I wouldn't
have to write "\\\" all the time. Of course, C# has @"" just to deal with that
latter problem.

~~~
torme
So I'm sort of nitpicking your comment here, but the purpose of @"" for
verbatim strings wasn't created just to deal with directory slashes, it's just
a handy way of writing string without the need for escaping in general.

Also, if you really want to make portable C# code, you should use
Path.DirectorySeparatorChar, as it's not platform specific at all.

[http://msdn.microsoft.com/en-
us/library/system.io.path.direc...](http://msdn.microsoft.com/en-
us/library/system.io.path.directoryseparatorchar.aspx)

------
makecheck
What bugs me is that they chose a character right next to "Return" on the
keyboard. For some reason no PC keyboard has moved it.

I've had embarrassing MS-DOS moments in the past where I was typing out
something like a recursive-delete on a path. If you accidentally hit RETURN
instead of a backslash then you can do things like blow away entire parent
directories unintentionally. This didn't exactly improve my already-critical
view of PCs. :)

~~~
chimeracoder
It's funny to think of how standardized keyboards are within the US today, and
yet it wasn't so long ago that you couldn't even count on the arrow keys being
in the same place (or in fact, being there at all - which is why you have hjkl
on Vim to this day.

On the other hand, the computers at Bell Labs had an arrow key, which is why R
(which is based on S) uses '<-' for assignment, as the two-character
combination was enabled for compatibility reasons.

And on a related note, I can't imagine how people use Vim without rebinding
ESC to Caps_Lock. Given that ESC used to be where TAB currently is (and the
latter is too useful to be removed), I don't really see a point in keeping the
obsolescent Caps_Lock, especially when it's so irritating to keep moving the
hand to the furthest corner of the keyboard.

~~~
cahrens
I usually swap the left ctrl and the Caps lock keys, mostly out of habit from
the first computer I used (An actual computer, with the Magnetic Tape spools
and punch-card boot loader).

I have also dealt with crappy tiny keyboards that don't even have any keys
beyond the standard chunk (So no function keys, 10-key, or arrows / browsing
control)

------
rwmj
In Microsoft tradition, this article completely ignores the fact that DOS was
a CP/M clone bought wholesale from another company (originally called QDOS).
The question is, did QDOS have / for command line switches? Or were all of
these tools added (as the article implies) by Microsoft engineers later?

[I didn't use QDOS, but I did use CP/M and it had the most unholy command line
syntax. I _don't_ fondly remember PIP...]

~~~
jgrahamc
No, QDOS (86-DOS) did not have switches. IIRC none of the commands had any
options at all. It did, however, have nice CP/M compatibility because there
was a command (RDCPM?) that allowed you to read from CP/M formatted media.

------
program
This article remind me of my first days of C coding and the problems generated
with escaped "c:\haracters in strings".

After years I still think that the use of forward slash is the worst decision
ever. At least Apple chose ":" on Mac OS classic.

~~~
harshreality
If you're referring to \ it's a backslash not a forward slash.

~~~
RegEx
A simple way to remember forward/backslash (which I probably read on HN) is
the phrase "Backslash is by the backspace"

Edit: This is for the standard US keyboard. A more general way of thinking
about it, though a bit more to remember: associate "positive" with "forward",
and see that '/' has a positive slope. Or just go listen to a BBC podcast, and
let the sound of the broadcaster saying "bbc dot co dot uk forward-slash
newspod" resonate in your head.

~~~
rue
It doesn't really make sense. Given we use a left-to-right and up-to-down, \
can be seen slashing forward in writing direction, starting from the top, and
/ backward.

Upslash / and downslash \ would make more sense, but this is what we have. My
mnemonic is that forward and back are the opposite of what makes sense.

~~~
RegEx
There's no one right way to remember something. I'm glad you found something
that works for you!

------
alanh
Relevant to this, one of the most popular posts I’ve ever written:
[http://alanhogan.com/tips/php/directory-separator-not-
necess...](http://alanhogan.com/tips/php/directory-separator-not-necessary)

------
alanh
Argh, second word of second paragraph is “answer’s”, an attempted
pluralization of “answer”?

Argh!

Will continue reading anyway, and will lose karma for this, but shit, does no
one even read their shit after publishing anymore?

