18 ms·
Why is the DOS path character "\"? (2005)
- lifthrasiir 6y agoIn 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.
- 4cao 6y agoOne 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/biographies/bemer_bob.htm https://web.archive.org/web/20100612011533/http://thocp.net/...
- lifthrasiir 6y agoI 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.)
- 4cao 6y ago> 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 https://en.wikipedia.org/wiki/Backslash#History
- Taniwha 6y agoWhile it was included in early character sets it just wasn't used much - largely because the ubiquitous 029 card punch had no \ key (or [] ... one had to learn the multipunches)
- 0x0 6y agoC also has trigraphs, in case your keyboard does not have a \ you can type ??/ instead. https://en.wikibooks.org/wiki/C_Programming/C_trigraph https://en.wikibooks.org/wiki/C_Programming/C_trigraph
- IgorPartola 6y agoMind blown. C is truly a terrifying language and I can’t help but love it for that.
- zinekeller 6y agoIt was designed in a time where keyboards around the world (German QWERTZ, Cyrillic JCKUEN/ЙЦУКЕН) and text encoding (remember that this is pre-Unicode, so we're dealing with ISO 646 and Eastern Asian character sets) has only the subset of Latin characters used in the US. Nowadays, it is strongly recommended to simply use the standard American keyboard in programming (outside of comments).
- samus 6y agoI still cannot decide whether it's better to comment in English or in my native language. English works, but it's a weird fit with words from the application domain. Those, I don't really want to translate, but I have to keep doing it because there is so much legacy code with the translations. Sure, I could do a rampage through the code base and fix everything up (would be done in an afternoon thanks to IntelliJ), but my team would almost certainly give me lots of flak for this. At the same time, it also feels weird to conjugate english words in my native language.
- mycall 6y agoI wonder how many regex security filters would break using ??/ for escape because very few people know this exists.
- dada78641 6y agoApparently there are several digraphs too. Convinced this was secretly just designed to make IOCCC contests more interesting.
- jimmaswell 6y agoI feel like some people must have written slashes in whatever direction long before, but it was never formalized until then.
- fjfaase 6y agoOne reason might be that DOS used the "/" character for options, whereas in other operating systems the "-" character is used.
- peteri 6y agoI 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/slash-versus-backslash-as-directory-separator-what-who-caused-this-rift/ https://retrocomputing.stackexchange.com/questions/4695/slas... where there is some discussion of the history. Along with https://retrocomputing.stackexchange.com/questions/7030/why-did-unix-use-slash-as-the-directory-separator/ https://retrocomputing.stackexchange.com/questions/7030/why-... and https://retrocomputing.stackexchange.com/questions/4686/where-do-command-line-switches-originate-from https://retrocomputing.stackexchange.com/questions/4686/wher...
- rnhmjoj 6y agoFrom 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.
- account42 6y agoYeah but imagine having to use Shift for every path separator you type.
- TheCycoONE 6y agoKeyboards may have evolved differently to compensate. The location of non-alphanumeric characters wasn't so consistent back then.
- hibbelig 6y agoGermans type Shift+7 to get /. Imagine their horror when having to type AltGr+- to get a backslash. At least with Shift you can choose which of the Shift keys to use, but there is only one AltGr key (it is to the right of the spacebar, the US keyboard layout has the right Alt key there). It used to be you could use Ctrl+Alt+-, too, and at least those were available on the left hand side, too. But I do not know if Ctrl+Alt works nowadays.
- apples_oranges 6y agoTL;DR: Because the / character was used for options. (as opposed to -, on UNIX)
- 4cao 6y agoAt 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 https://news.ycombinator.com/item?id=26272844 So in principle they could have thought of having something like PATHCHAR=/ as well.
- simonh 6y agoIn 2007 I joined a company that sold a derivatives trading platform and ran VMS on the core component, the order routing engine that dispatched trading instructions to the respective exchange. It was really weird working on it at first after having used both Unix systems and DOS for so long. I was very familiar with DOS and even used CP/M way back in the day when I was a teenager (I'm that old), VMS was a weird amalgam of a pretty advanced OS with a very capable command line environment like unix, but with a lot of conventions that felt familiar from DOS. I was a ware of some of the history of VMS influence on DOS so it was fascinating to work on and I quite enjoyed it even though it was clearly a dead end at that point.
- kiwidrew 6y agoThanks 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 Unix even more: AVAILDEV = <TRUE or FALSE> The default is TRUE which means both /dev/<dev> and <dev> will reference the device <dev>. If FALSE is selected, only /dev/<dev> refers to device <dev>, <dev> by itself means a file in the current directory with the same name as one of the devices. Finally, an example CONFIG.SYS file from the same document: A typical configuration file might look like this: BUFFERS = 10 FILES = 10 DEVICE = /bin/network.sys BREAK = ON SWITCHAR = - SHELL = a:/bin/command.com a:/bin -p I think it's pretty clear how Microsoft intended for MS-DOS to be configured, but alas IBM had other ideas... [1] https://github.com/microsoft/MS-DOS/blob/master/v2.0/source/XENIX.ASM https://github.com/microsoft/MS-DOS/blob/master/v2.0/source/... [2] https://github.com/microsoft/MS-DOS/blob/master/v2.0/bin/CONFIG.DOC#L60 https://github.com/microsoft/MS-DOS/blob/master/v2.0/bin/CON...
- emptyparadise 6y agoI 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.
- PostThisTooFast 6y agoThat seems lame as hell. Isn’t / a switch only when preceded by a space? Then what’s the problem?
- r00f 6y agoCan 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?
- skissane 6y agoBecause 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.
- r00f 6y agoI see, didn't know that
- pjc50 6y agoYes, and this is absolutely maddening when trying to do cross-platform work because some programs support / in filenames while others interpret them as arguments. (Another key difference is that on UNIX the shell expands '*' before passing it to a program, but CMD doesn't so each program has to do its own globbing)
- ynik 6y agoPretty much all Windows programs support / in filenames. The main issue is some cmd builtins like mkdir/cd/del which have weird parsing rules where every / is interpreted as starting a command-line switch, even if not preceded by a space. But even there, you only need to use quotes (mkdir "c:/test") to suppress the interpretation as a switch and then you can use paths with slashes just fine in batch files.
- kijin 6y agoEven worse, there was (and still is) no requirement for a command and its switches to be separated with whitespace. "DIR/W" is the same as "DIR /W". Which would have made it impossible to determine whether you want to invoke the command "DIR" in the current directory, or the command "W" in a subdirectory named "DIR".
- DrBazza 6y agoProbably the second most expensive mistake after 'null'. Discuss... :)
- burntoutfire 6y agoWhat 'null' mistake?
- DrBazza 6y agoTony Hoare apologising for inventing the null reference: https://en.wikipedia.org/wiki/Tony_Hoare#Apologies_and_retractions https://en.wikipedia.org/wiki/Tony_Hoare#Apologies_and_retra... > This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years.[26] So much time, and therefore money, working around `\` escaping characters in file paths.
- toolslive 6y agohm, because of CP/M, no? it's also where the drive letters came from (and some command names)
- inglor_cz 6y agoYou mean CP\M? :-)
- deleted 6y ago[deleted]
- agys 6y agoIt bothered me as a kid that the (ROM) font used in DOS had different thickness for slash and backslash… it wasn’t just a mirrored glyph. https://int10h.org/oldschool-pc-fonts/fontlist/font?ibm_ega_8x14 https://int10h.org/oldschool-pc-fonts/fontlist/font?ibm_ega_...
- Minor49er 6y agoMe too, particularly since some of my favorite programs (various DOS games, especially MegaZeux) used text mode for their graphics
- hackerbabz 6y agoDo 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.
- veltas 6y agoI don't have an answer but it's exactly the same phenomenon as when people refer to '#' as a hash-tag.
- timoth3y 6y agoExactly. Everyone knows it's an octothorp.
- paulmooreparks 6y agoJust don't call it "pound" when standing in Britain. :)
- veltas 6y agoI 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.
- chasd00 6y agoi've just started calling it "shift 3". that seems to be the least confusing way to communicate the character haha
- pwinnski 6y agoThat will usually work in the US, but Shift-3 returns £ on keyboards configured for the UK!
- SulphurCrested 6y agoIt was an unfortunate choice because \ is one of the 12 characters that vary between country versions of ISO 646 (of which ASCII was the US profile). This was why Japanese MS-DOS used ¥ instead of \ for the directory separator: it occupied the same code point in the Japanese profile of ISO 646 that \ did in ASCII, and Shift-JIS encoded that as a single byte with the high bit clear. The complete list of the 12 was: # $ @ [ ] \ ^ ` { } | ~. Notice that / is safe. They avoided the problem for all the Western languages by inventing their own 8-bit code (this was before the ISO 8859 standards) and always using ASCII in the lower half.
- timonoko 6y agoAll wrong. "/" was the options-switch-character in CP/M, which had no sub-directories. DECs and VAXes had nothing to do this decision, because only few humans had access to such machines. I even remember I had problems adapting to directory trees in MSDOS because files were kinda hidden and lost in a floppy directory.
- tgv 6y agoCP/M had them because of DEC, IIRC. Commands like "DIR" and "TYPE" are also indicative. And "PIP".
- culturedsystems 6y agoCP/M was surely the direct influence. Wikipedia says CP/M was itself influenced by TOPS-10, which I think also used the slash for options, so the ultimate origin may be with DEC.
- simonh 6y agoIt's true that DOS was originally a CP/M clone, but CP/M didn't have a defined standard option switch character, and in fact many command option switches weren't preceded by a switch indicator or differed as to what option switch character was used. If anything + and - were the most common prefixes for an option switch. http://www.cpm.z80.de/manuals/cpm3-cmd.pdf http://www.cpm.z80.de/manuals/cpm3-cmd.pdf The article is quite right that the convention of using / for command line switches came from IBM.
- emondi 6y agoWhere it says FileName.Extension[,Version] MONITR.EXE,4 What was the version used for? Did it track the changes?
- SloopJon 6y agoI don't know about DEC-20, but on VMS, changing a file makes a copy with a new version number: $ edit foo.txt ... Ctrl-Z $ dir foo.txt;1 $ edit foo.txt ... Ctrl-Z $ dir foo.txt;1 foo.txt;2 When you delete a file, you have to specify a version field (blank for latest): $ del foo.txt; $ dir foo.txt;1 IIRC, you can configure how many versions to keep.
- vincent-manis 6y agoThe version number was used the same way in TOPS-20 (which I never used) and Tenex, its predecessor (which I did). Emacs still has a facility for numbering backup files in the same way.
- tragomaskhalos 6y agoYes that's right, the versions to retain was configurable, and the whole versioning mechanism was really useful and a great miss from today's OSes. The VMS file and directory syntax otoh was a real pain, Unix definitely wins there.
- greggman3 6y agoPersonally I find unix or whatever OS chose / as the bad choice. / is a commonly used character, at least in the USA as dates. It would completely normal for someone to want to name a file "Meeting 12/20/1980.txt" or "Budget Sep/12/1985.doc" Backslash has no common use I know of outside of computer related stuff like regular expressions and escaping things. Some of you might also have forgotten but on Mac pre OS-X, at least in standard Mac devtools provided by Apple the separator was colon :
- kps 6y agoBackslash has no non-computer use since it was invented for ASCII to represent ‘∧’ and ‘∨’ as ‘/\’ and ‘\/’.
- michaelcampbell 6y agoMy son used to use \ for dates when he was learning to write; to the point I wondered if he was somewhere above 0 on the dyslexia scale. He's 20 now, and I think has grown out of it.
- jhallenworld 6y agoRM/COS used . as a path separator. I think this is from OS/360. It makes sense to me in that member selection in C also uses '.'. Yeah, from the OS/360 wiki: "The file naming system allows files to be managed as hierarchies with at most 8 character names at each level, e.g. PROJECT.USER.FILENAME. This is tied to the implementation of the system catalog (SYSCTLG) and Control Volumes (CVOLs), which used records with 8 byte keys."
- bsenftner 6y agoThe person that made this decision was the author of the original DOS - Al (Allan) Alcorn. I had a conversation with him nearly 2 decades ago about this very subject. I remarked to him how using the "opposite slash" caused grief for untold numbers of developers. His reply was "yeah, I know. It was a poor decision, and I remember it clearly. I was trying to make DOS a bit unique, and that was all. It was stupid, in retrospect." From the author's mouth.
- chasd00 6y agoFunny, i've always imagined it was chosen only because it wasn't a regular slash like other systems. I never mentioned it though because i figured I was wrong.
- hilbert42 6y agoDuring 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 good sandwiches). One of the people who toured us around was a DOS developer (who in his 'spare' time also contributed to the Flight Simulator development). He spent considerable time discussing the new DOS subdirectory matter as it was a hot topic back then. Anyway, he received somewhat of a tongue-lashing from us about the backslash 'problem' and it was very clear to us that he too was not in favor of it although for obvious reasons he chose his words carefully. This brings me to more ergonomic problems that Microsoft has never bothered to solve with its operating systems—DOS or Windows. The first I'll mention is the annoying reserved character problem, specifically: < > : " / \ | ? * cannot be used in a filename. I'm aware these characters are also deemed illegal in the filenames of other operating systems but I fail to see why after about 30 years that we still have to worry about avoiding them. If Microsoft had fixed the problem back then, then there would have been pressure for other operating system developers to also fix the problem. Just because other operating systems were behind the times, it didn't mean Microsoft had to be—after all, in the early days, Microsoft went to considerable trouble to please users in the useability stakes, even to the extent that it put security severely at risk in the process. I fail to see why Microsoft couldn't have coded around this problem and allowed the use of these characters. It went part of the way by allowing spaces within filenames in Windows and it also allowed spaces to be entered into the command line filenames with quotes "My first Name.doc". The fact that these characters cannot be used has caused considerable trouble for IT staff over the years. It'd hate to think how many thousands of hours have been wasted by both users and IT staff over the past three decades or so on what ought to have been a trivial matter to fix. Similarly, I hate to think how many times I've had to enter a ¿ into a filename just because the damn operating system will not let me enter normal question mark: ?. Another major stuff-up is the maximum filename length/max path length of 254/255 - 260 when the path length could be potentially 32,767 characters—as it already calculates the path to this length internally (the exact length varies between O/S versions). These days, this limit is ridiculous. If, say, you have a file with a filename of say 245 characters long in directory \MyFiles then move the directory way down deep into nested directories then one automatically has a problem that one's not necessarily aware of until a cannot-continue crash occurs during a backup. Having to regularly run a Max-Path-Length utility across the disk to search for potential problems is a damn nuisance and it ought to be completely unnecessary. Same problem occurs when saving web pages with long names, these often exceed the maximum filename length and the page cannot be saved without manual intervention. To say ≈255 characters for a filename is long enough is just not being realistic these days. Here's another instance: say one wants to save a book with a long title from the Internet Archive and to avoid confusion later over having a cryptic filename one adds the book's title to the already-cryptic IA filename, i.e.: Books.<…>.with_very_long_names_are_common_on_the_IA_+_the_Internet_Archive_filename_abcxzy123.pdf Many a time I've had the title combined with the IA O/S filename exceeds 255 characters, and sometimes it's by a large margin. Shortening the filename at this juncture wastes considerable time, especially if there are many files involved. Oh, and there's another PIA worth mentioning: .MSI files cannot be loaded from a directory when the directory has a leading blank (space) in its filename whereas an .EXE file can. Now how did that come about (and it's never been fixed)? [Leading spaces in directories are useful as directories and files are automatically sent to the top of the file manager tree—which is a very useful technique I've adopted for years to highlight temporary work files or sorting directories, etc. Again, this is necessary due another operating system limitation, which is that neither DOS nor Windows has any way of allowing a user to order the file/directory structure to meet his or her needs.] Other obvious limitations are that we cannot highlight filenames or directories in that we cannot make them different colors or even have filenames with different typefaces. Why not? As I've said for years, operating system developers don't care much about user ergonomics. If they did then by now we'd even have a new file system to replace the existing one which is truly antiquated. A new file system would include metadata extension(s) within files that OSes and programs would both understand (but that's a far too big a matter to discuss here). When one thinks about it, we users really have been shortchanged by the likes of Microsoft and others over the years.
- ratsmack 6y ago>*nix defines hierarchical paths with a simple hierarchy rooted at "/" - in *nix's naming hierarchy, there's no way of differentiating between files and directories, etc (this isn't bad, btw, it just is). I don't see the problem, but I guess it's just a personal preference.
- thesuitonym 6y ago>this isn't bad,btw,it just is
- ChrisArchitect 6y agowhy post this wayback version? Post is still up here: https://docs.microsoft.com/en-us/archive/blogs/larryosterman/why-is-the-dos-path-character https://docs.microsoft.com/en-us/archive/blogs/larryosterman... and anyways, (2005).... here's plenty of other discussion from one of the previous posts: https://news.ycombinator.com/item?id=3723355 https://news.ycombinator.com/item?id=3723355