Live data from Hacker News

Why is the DOS path character "\"?

blogs.msdn.com

1–10 of 68 posts

Re: Why is the DOS path character "\"?

#2
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.

Re: Why is the DOS path character "\"?

#3
post #2

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.

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

Re: Why is the DOS path character "\"?

#4
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.

Re: Why is the DOS path character "\"?

#5
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...]

Re: Why is the DOS path character "\"?

#6
post #2

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.

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

In my time supporting naive endusers, it's always amused me that people at a level where they have trouble with left and right mouse buttons can remember slash and backslash like pros.

Re: Why is the DOS path character "\"?

#7
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]

Re: Why is the DOS path character "\"?

#8
post #2

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.

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

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.

Re: Why is the DOS path character "\"?

#9
post #5

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...…

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.

Re: Why is the DOS path character "\"?

#10
post #5

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...…

CP/M did not have directories as well.
Post reply on HN