[HN Gopher] Why Does Windows Use Backslash as Path Separator? (2...
       ___________________________________________________________________
        
       Why Does Windows Use Backslash as Path Separator? (2019)
        
       Author : susam
       Score  : 54 points
       Date   : 2022-02-28 15:04 UTC (7 hours ago)
        
 (HTM) web link (www.os2museum.com)
 (TXT) w3m dump (www.os2museum.com)
        
       | adrian_b wrote:
       | The article is slightly misleading about the usage of the forward
       | slash in CP/M.
       | 
       | It is true that the CP/M operating system itself did not use the
       | forward slash, but the only reason for that was that the
       | operating system included only a handful of executable programs,
       | the main being the equivalents of the later "COMMAND.COM",
       | "DEBUG.COM" and "COPY.COM" of Microsoft.
       | 
       | The very few executable programs provided with the OS did not
       | have any command-line options. A few of the most common file
       | operations were shell built-ins, not separate executable
       | programs.
       | 
       | On the other hand, most CP/M executable programs (which were
       | bought from third parties, not from Digital Research, the vendor
       | of CP/M) had command-line options and, without exceptions, they
       | used the forward slash for command-line options, instead of the
       | hyphen used by UNIX.
       | 
       | It would have been absolutely impossible to use CP/M without
       | being aware of the convention that the forward slash is used for
       | the command-line options.
       | 
       | The article is completely correct that the use of the forward
       | slash for options was not introduced by CP/M, but it was taken
       | from the operating systems of the DEC Corp., which, during the
       | seventies, were much more widely used than UNIX, which was an
       | alternative for them only on PDP-11, and it was not yet used much
       | outside the Bell Labs.
       | 
       | Nevertheless, all the programs ported to MS-DOS 1.0 (e.g. MS
       | BASIC, Turbo Pascal, WordStar, dBASE and so on) had not been
       | ported from programs written for DEC OSes, but from programs
       | written for CP/M.
       | 
       | There is no doubt that the forward slash of MS-DOS 1.0 is
       | directly inherited from CP/M. It was used by the same programs,
       | for exactly the same options, so they must have kept the command-
       | line parser without changes. I have used many of the same
       | programs both first for CP/M and then for MS-DOS, so I can be
       | certain about this.
       | 
       | I have also used the DEC RSX-11M operating system on PDP-11, and
       | indeed the RSX-11M utilities, for example PIP (Peripheral
       | Interchange Program, a file transfer program with many options,
       | somewhat like UNIX dd), used the forward slash many years before
       | CP/M and most programmers for CP/M should have been familiar with
       | this convention, so they have reused it, but the relationship
       | from DEC OSes to MS-DOS 1.0 is indirect, via CP/M.
        
         | pwdisswordfish9 wrote:
         | There is no COPY.COM.
        
       | layer8 wrote:
       | Another difference from Unix is that Windows does not always
       | normalize multiple consecutive backslashes or slashes to a single
       | one. A path like "foo\\\bar" (or "foo//bar") gets you "The file
       | name is not valid" in File Open dialogs, for example.
        
       | erwincoumans wrote:
       | Aside from the backslash history, Windows is very impressive in
       | preserving backward compatibility. I still use a few programs
       | over 20 years old (including JASC Paintshop Pro 7 from 2000, the
       | 10 year old anniversary edition) and they still run on Windows
       | 10.
        
       | zelphirkalt wrote:
       | Some programming language(s?) seem to have taken over this
       | strange characteristic: PHP. While most other languages use the
       | backslash as an escaping symbol, in PHP you have it as a path
       | separator in imports. It is not so nice.
        
         | mattl wrote:
         | Isn't it used for namespacing in PHP?
        
         | drekipus wrote:
         | I'd be hard pressed to find anything nice about PHP
        
       | gatonegro wrote:
       | > The ergonomics of non-US keyboards were naturally not
       | considered, which caused the path separator to be ridiculously
       | difficult to type on some national keyboards (e.g. German),
       | perhaps as a perverse reminder that ergonomics do matter.
       | 
       | The more I've shifted towards a keyboard-centric workflow, the
       | more I'm feeling this lack of consideration regarding non-US
       | layouts. When using a Spanish keyboard, the placement of
       | characters like forward slashes, backslashes, tildes, pipes, etc.
       | can be _physically_ painful after an extended typing session. I
       | 'm considering either getting a US keyboard, or doing some
       | serious keyboard map tweaking.
       | 
       | It's somewhat amusing to think that my current ergonomic
       | predicaments are essentially the result of operating system and
       | keyboard design choices and conventions that are over half a
       | century old at this point.
        
         | Nitrolo wrote:
         | I have a fairly keyboard centric workflow as well, and I didn't
         | notice this until a few months ago I got a laptop with a US
         | keyboard.
         | 
         | Suddenly all those key bindings and symbols made sense, or at
         | least were somewhat reachable without contorting my hands. I
         | never noticed how terrible DE keyboards are for programming
         | before but I don't want to go back.
        
       | Maursault wrote:
       | > Both Windows 9x and NT were directly or indirectly derived from
       | DOS and OS/2,
       | 
       | False, or perhaps only true for "Windows NT" before Dave Cutler
       | and his team developed it while working for Digital. After Cutler
       | arrived at Microsoft and took over development of NT there (i.e.
       | replaced it with the OS he developed at DEC at... not sure NT
       | 4.x? ), Windows NT was no longer _derived_ from DOS, rather, DOS
       | was ported to Cutler 's OS. The last OS derived from or based on
       | DOS may have been Windows ME.
        
         | voidfunc wrote:
         | Yea Windows NT is really VMS evolved and there is the joke that
         | WNT is VMS++.
        
         | chaoticmass wrote:
         | I think the author is referencing how IBM and Microsoft
         | originally went in on developing OS/2 as a joint venture, but
         | then when they split ways, MS allegedly* took it's work on OS/2
         | and used it as a starting point for NT.
         | 
         | I say allegedly because this was just passed around as sort of
         | 'common knowledge' in OS/2 community groups back in the late
         | 90's. I've never seen it actually verified.
        
       | gdulli wrote:
       | Are there contexts where the backslash is still required? I've
       | been using the forward slash in Windows for years. It works from
       | Python, it works from the command prompt, it works in Explorer.
       | But I don't know if that means it's completely redundant or if
       | some places still require it.
        
         | jaclaz wrote:
         | Also, the Registry.
         | 
         | And BTW .reg files need to double the backslash because it is
         | parsed as an escape character.
        
         | dfawcus wrote:
         | At the API level, both '/' and '\' have been accepted since
         | sub-directories were added to DOS.
         | 
         | It was only ever at the UI (command prompt), and in how some
         | programs converted inputs and outputs where '\' was necessary,
         | as the knowledge about '/' being usable wasn't all that
         | widespread.
         | 
         | What used to peeve me was C source on DOS development
         | environments with lines like:                 #include
         | "path\\to\\file.h"
         | 
         | When the following always seemed to work (with the compilers I
         | used):                 #include "path/to/file.h"
         | 
         | Or at least it did with Borland compilers.
        
         | electroly wrote:
         | Because the forward slash is used for command line flags, there
         | can be ambiguity when using forward slashes in paths that does
         | not exist if using backslashes. Consider a directory on your
         | root C: drive called "D". In a command prompt:
         | 
         | cd \D <-- This takes you to the C:\D\ directory.
         | 
         | cd /D <-- This is an error because /D is a flag.
        
           | paulmooreparks wrote:
           | True, but quoting the path will work: cd "/D"
        
             | electroly wrote:
             | No, it doesn't. Try it and see for yourself. Make sure
             | you're using Command Prompt and not PowerShell.
        
             | adtac wrote:
             | How? Wouldn't the program's argv see the same string with
             | and without quotes? Or is that just a *nix thing?
        
               | schroeding wrote:
               | cd is a built-in of the shell / cmd, not an application,
               | it does not use argv, AFAIK.
               | 
               | It should, as you said, not work for normal applications
        
               | johnny22 wrote:
               | nope. I read an article about this when i accidentally
               | broke the arg parsing for wildcards. worked fine in
               | linux, but not on windows :(
        
         | layer8 wrote:
         | It's required when passing a path as argument to Explorer. That
         | is, when you type "explorer C:/" in the Run box or on the
         | command line, Explorer opens in the default folder instead of
         | in C:\\. That's probably because Explorer also accepts URLs, so
         | "explorer file://C:/" does work. For some reason, the Explorer
         | address bar behaves differently.
        
         | edflsafoiewq wrote:
         | I think \\\?\ paths require backslashes.
        
         | Something1234 wrote:
         | It doesn't tab complete the path if you use forward slash in
         | windows batch. I think forward slash works right in PowerShell,
         | but I might be mistaken.
        
           | mshockwave wrote:
           | it works just fine in PowerShell and the new Windows Terminal
           | but yeah, I doubt CMD will do auto-complete for you w/
           | forward slash
        
             | EvanAnderson wrote:
             | It will not. It completes out of the current directory when
             | trying to TAB-complete following a slash.
        
           | infogulch wrote:
           | Powershell will autocomplete forward-slash paths and convert
           | them to back slashes.
        
         | joshuaissac wrote:
         | They are still needed in UNC paths like \\\server\\...\\.
        
           | dgrunwald wrote:
           | UNC paths like //server/share/ are perfectly fine.
        
             | EvanAnderson wrote:
             | CMD and Windows Explorer don't like that. Powershell
             | handles it fine.
        
             | [deleted]
        
             | joshuaissac wrote:
             | I tried it in Windows Explorer on Windows 10, and it just
             | launches the browser for me instead of opening the folder.
        
       ___________________________________________________________________
       (page generated 2022-02-28 23:00 UTC)