Live data from Hacker News

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

web.archive.org

151–160 of 166 posts

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

#151
post #47

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.

C also has trigraphs, in case your keyboard does not have a \ you can type ??/ instead. https://en.wikibooks.org/wiki/C_Programming/C_trigraph

Apparently there are several digraphs too. Convinced this was secretly just designed to make IOCCC contests more interesting.

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

#152
post #104

Earlier quoted context omitted.

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

> the problem is caused by Unix allowing any character in filenames (other than slash and null). Most Unixes don't allow any character; they allow any byte other than ascii slash or zero. Turning bytes into characters is outside the scope of most Unix kernels and the filesystems therein.

> Turning bytes into characters is outside the scope of most Unix kernels and the filesystems therein.

All the major contemporary Unix(-like) kernels do have code in them to do file path charset translation. It is very important when dealing with removable media (ISO-9660, UDF), FAT filesystems, network filesystems (especially CIFS/SMB, but even some NFS implementations), filesystems defined in terms of Unicode such as NTFS, HFS+, APFS.

Traditional Unix filesystems don't do this, but they were originally designed at a time when few clearly distinguished the concept of byte from the concept of character.

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

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

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

Agreed!

Shell scripting would be so much more sane (and safe) if filenames couldn't contain spaces (or control chars) and couldn't begin with a '-' character. Then the shell's default $IFS would work as intended in the presence of pathname expansion, and there would be no need to use '--' to delineate the filename arguments from the option arguments when executing commands.

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

#155
post #106

Earlier quoted context omitted.

Except C:/ is not a command option, and only Unix people would write "/"

Sounds a bit provincial. That might have been true before mainstream internet access, but the average user these days is likely more familiar with unix style paths via URLs than local filesystem paths. Also, most non-unix operating systems that don't happen to be made by Microsoft also use the forward slashes for paths.

> the average user these days is likely more familiar with unix style paths via URLs than local filesystem paths

The average user ignores the contents of the address bar. "That's all tech gobbledegook". Increasingly, browsers even hide its contents from the user, just displaying the domain name, making the average user even less aware of it.

> Also, most non-unix operating systems that don't happen to be made by Microsoft also use the forward slashes for paths.

What are "non-unix operating systems that don't happen to be made by Microsoft". Non-Microsoft operating systems in common use – Linux (including Android), macOS/iOS/Darwin/XNU, *BSD – are Unix-like, and hence I wouldn't really call them "non-unix" (even if they are not strictly speaking certified as such)

If we look at non-Microsoft non-Unix(-like) operating systems (none of which are commonly encountered nowadays), we see a lot which use neither forward nor backslashes for directories. For example, OpenVMS and RISC OS both use dots, classic MacOS used colons. Stratus VOS uses the greater-than sign, which it inherited from Multics. The IBM mainframe operating system MVS (nowadays called z/OS) uses dots to separate the components of a dataset name – although those components aren't exactly directories. (It also supports forward slashes in its Unix compatibility subsystem, but that wasn't around for the first 25 years of its existence.)

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

#156
post #126

During the time DOS 2.0 was in development, I visited Microsoft with a group of colleagues. (We were touring computer manufactures both in Seattle and in Silicon Valley (where we visited Digital Research, Intel and many others—in those days it was comparatively easy to visit these enterprises for a tour.) We were at Microsoft quite some hours (and we seemed important enough to be fed lunch which consisted of very goo…

> If Microsoft had fixed the problem back then, then there would have been pressure for other operating system developers to also fix the problem. I don't know about all of the other reserved characters, but the colon is the path-separator character in classic Macintosh APIs and I doubt they would have ever been able to "fix" that. > To say ≈255 characters for a filename is long enough is just not being realistic the…

I was happy when I learned that "Docume~1" worked for "Documents and Settings".

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

#157
post #73

Do you correct people when they say “back slash” when reading out a url? When it’s actually a forward slash? Is there a name for this phenomenon? Everyone knows it’s a slash except when its used for something computery. Then it somehow becomes a backslash.

I don't have an answer but it's exactly the same phenomenon as when people refer to '#' as a hash-tag.

That's not the same at all. Hash-tag is just a name for that symbol. It's not the original name, but it is a name. "/" is slash! "\" is a backslash! People who do not type windows paths have probably never actually encountered a backslash in their entire lives, but when they see a url they think that the symbol they see all the time in other contexts (/) suddenly has a different name!

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

#158
post #73

Earlier quoted context omitted.

I don't have an answer but it's exactly the same phenomenon as when people refer to '#' as a hash-tag.

That's not the same at all. Hash-tag is just a name for that symbol. It's not the original name, but it is a name. "/" is slash! "\" is a backslash! People who do not type windows paths have probably never actually encountered a backslash in their entire lives, but when they see a url they think that the symbol they see all the time in other contexts (/) suddenly has a different name!

A 'hash-tag' is a feature of internet apps like Twitter where you put a '#' in front of some topic name to relate your content with similar content. It's named after the character which is known as a 'hash' among other things.

Or are you saying 'hash-tag' is the name because although it's a mistake it's used so much now it's considered language?

Language isn't one big blob, even though among many people it could now be considered an alternative pronunciation, and eventually it could be adopted even in places where people would otherwise know better, right now among people in tech and certainly on this site 'hash-tag' to mean the character is incorrect and confusing.

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

#159

Earlier quoted context omitted.

Exactly. Everyone knows it's an octothorp.

Just don't call it "pound" when standing in Britain. :)

I live in Britain and don't have an issue with it, '#' is originally a symbol for pounds, a shorthand for 'lb', and we are used to the idea that pounds can mean weight, as well as our currency, so why not this symbol as well?

It's believed the 'pound' in pound sterling came from a pound of silver or silver coins in weight originally as well.

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

#160

Earlier quoted context omitted.

That will usually work in the US, but Shift-3 returns £ on keyboards configured for the UK!

Is that related in any way to the fact that both symbols can be referred to as a 'pound' symbol, or is it a complete coincidence?

I believe it is related to them both being called 'pound', and it is very annoying. The two are not the same symbol, I don't know why they equivocated them. Technically in a distant root they are related, but they are distinct in usage and meaning.
Post reply on HN