Live data from Hacker News

Why is the DOS path character "\"? (2005)

web.archive.org

11–20 of 166 posts

Re: Why is the DOS path character "\"? (2005)

#11
post #3

One reason might be that DOS used the "/" character for options, whereas in other operating systems the "-" character is used.

I never understood why Unix chose "-" for options. It creates unnecessary confusion. E.g. when deleting a directory called "-rf"

Re: Why is the DOS path character "\"? (2005)

#12
post #3

One reason might be that DOS used the "/" character for options, whereas in other operating systems the "-" character is used.

Not sure if you realise but this is not an "Ask HN" post, it's a link to an article, which of course mentions the reason:

> They couldn't use the *nix form of path separator of "/", because the "/" was being used for the switch character.

Re: Why is the DOS path character "\"? (2005)

#14
post #6

Thanks to Microsoft's recent release of the MS-DOS 2.0 source code, we can now peek under the hood and confirm that Microsoft specifically intended for the DOS 2.0 file APIs to be compatible with Unix. From XENIX.ASM [1], the code that implements the new API: ; ; xenix file calls for MSDOS ; TITLE XENIX - IO system to mimic UNIX And the CONFIG.DOC [2] file discusses the 'AVAILDEV' option which lets the system mimic U…

I really look forward to the day NT's source is released. It's a truly fascinating kernel. Imagine somebody building an entire Unix on top of NT! Like WSL, but even beyond.

What special about NT kernel that's not in linux kernel ?

Re: Why is the DOS path character "\"? (2005)

#15

In addition to its use as a path separator in DOS and Windows, the backslash character itself is also interesting because it is very likely a modern invention, with the first attestation in 1940s (!). Its original use in ASCII (1960s) was for ALGOL operator digraphs `\/` and `/\`. Its early use as the C escape sequence (1970s, replacing `*` in BCPL) suggests that it carried no significant semantics at that time.

One of the comments on that blog post says the backslash was invented by Bob Bemer at the time he developed ASCII in the 1960s, also linking to a page that supports the claim:

https://web.archive.org/web/20100612011533/http://thocp.net/...

Re: Why is the DOS path character "\"? (2005)

#16
post #11
post #3

One reason might be that DOS used the "/" character for options, whereas in other operating systems the "-" character is used.

I never understood why Unix chose "-" for options. It creates unnecessary confusion. E.g. when deleting a directory called "-rf"

Technically deleting a directory is done with the rmdir command. But rm with flags is flexible enough that I've seen very few people use rmdir

Re: Why is the DOS path character "\"? (2005)

#17

Earlier quoted context omitted.

I really look forward to the day NT's source is released. It's a truly fascinating kernel. Imagine somebody building an entire Unix on top of NT! Like WSL, but even beyond.

What special about NT kernel that's not in linux kernel ?

IOCP!

https://en.wikipedia.org/wiki/Input/output_completion_port

Re: Why is the DOS path character "\"? (2005)

#18
post #15

In addition to its use as a path separator in DOS and Windows, the backslash character itself is also interesting because it is very likely a modern invention, with the first attestation in 1940s (!). Its original use in ASCII (1960s) was for ALGOL operator digraphs `\/` and `/\`. Its early use as the C escape sequence (1970s, replacing `*` in BCPL) suggests that it carried no significant semantics at that time.

One of the comments on that blog post says the backslash was invented by Bob Bemer at the time he developed ASCII in the 1960s, also linking to a page that supports the claim: https://web.archive.org/web/20100612011533/http://thocp.net/...

I briefly checked comments and missed that. ;-) I would be more cautious to say that he invented backslashes, as it's unknown that he was aware of earlier uses of backslashes. (I've checked both the page and its citations and they gave no more information.)

Re: Why is the DOS path character "\"? (2005)

#19

TL;DR: Because the / character was used for options. (as opposed to -, on UNIX)

At the time (in MS-DOS 2.0) you could set SWITCHAR=- in CONFIG.SYS to override this setting. @kiwidrew's post above even has an excerpt from the source that demonstrates it:

https://news.ycombinator.com/item?id=26272844

So in principle they could have thought of having something like PATHCHAR=/ as well.

Re: Why is the DOS path character "\"? (2005)

#20
post #7
post #3

One reason might be that DOS used the "/" character for options, whereas in other operating systems the "-" character is used.

I have a feeling that the "-" character for an option is a unix (multics) only thing. It is also worth looking at https://retrocomputing.stackexchange.com/questions/4695/slas... where there is some discussion of the history. Along with https://retrocomputing.stackexchange.com/questions/7030/why-... and https://retrocomputing.stackexchange.com/questions/4686/wher...

From the third link:

> (I still think the Multics path seperator looks more natural >etc>bin - too bad Unix diverted here)

Looks more natural indeed. In fact it's visually similar to how paths are stylised in some file picker GUIs.

Post reply on HN