Live data from Hacker News

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

web.archive.org

31–40 of 166 posts

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

#31
post #23

Can anyone explain why was that a problem, from technical point of view? They already had paths starting with "driveletter:", not like unix with just "/". Why would it be a problem for parser to distinguish between filepaths and arguments switch?

Because paths don't have to start with a drive letter – a path like \foo\bar is relative to the current drive.

"DIR \W" does a DIR of the "\W" directory on the current drive.

"DIR /W" does a DIR listing in wide format.

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

#33
post #15

Earlier quoted context omitted.

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

> I would be more cautious to say that he invented backslashes

You're right of course, I was just relaying what the post there said. There was prior usage as early as in the 1940s as you mentioned. According to Wikipedia, [1] its origins are unknown:

> As of January 2021, Wikipedia editors have not been able to find the origin of this character nor even the purposes to which it was put before the 1960s. The earliest known reference found to date is a 1945 bulletin from the Teletype Corporation that lists it as a replaceable part for its Wheatstone perforator.

On the other hand, I think it's safe to say it would have remained an obscure character had it not been for Bob Bemer.

1. https://en.wikipedia.org/wiki/Backslash#History

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

#34

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 ?

Proper support for paged kernel memory? Async-by-default I/O? Must better power management (compare win vs linux battery life on same hardware).

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

#35
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"

Another viewpoint: the problem is caused by Unix allowing any character in filenames (other than slash and null). Other platforms are more restrictive in what characters filenames are allowed to contain. If you banned the '-' character from starting a filename, the problem wouldn't happen.

I personally think Unix allowing almost any character in filenames was a mistake. You can put newlines and other control characters in filenames. That has very little legitimate use, and is a potential source of security and other bugs. There is a proposal to amend the Unix standards to disallow control characters in filenames. But it doesn't look like it is going to be successful: https://www.austingroupbugs.net/view.php?id=251

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

#36
post #23

Can anyone explain why was that a problem, from technical point of view? They already had paths starting with "driveletter:", not like unix with just "/". Why would it be a problem for parser to distinguish between filepaths and arguments switch?

Paths can drop the drive letter e.g. del \file will try to delete a file in the root of the current drive.

On modern Windows you can use slash, but you have to quote the argument e.g. dir "C:/windows"

You can even mix both types together e.g. dir "C:/windows\system32" which is convenient when using code modules that only output unix style paths. No need to clean them up.

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

#37
post #16
post #11

Earlier quoted context omitted.

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

rmdir is usefull when you want to remove all empty subdirs, without touching files or directories with files. Just do 'rmdir *' and you're done.

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

#38
post #23

Can anyone explain why was that a problem, from technical point of view? They already had paths starting with "driveletter:", not like unix with just "/". Why would it be a problem for parser to distinguish between filepaths and arguments switch?

[deleted]

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

#39
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"

The only solution to that confusion would be not allowing the options identifying character in file/directory names. Changing the character would just "change" the confusion.

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

#40
post #23

Can anyone explain why was that a problem, from technical point of view? They already had paths starting with "driveletter:", not like unix with just "/". Why would it be a problem for parser to distinguish between filepaths and arguments switch?

Because paths don't have to start with a drive letter – a path like \foo\bar is relative to the current drive. "DIR \W" does a DIR of the "\W" directory on the current drive. "DIR /W" does a DIR listing in wide format.

I see, didn't know that
Post reply on HN