Stories
Slash Boxes
Comments

SoylentNews is people

SoylentNews is powered by your submissions, so send in your scoop. Only 19 submissions in the queue.
posted by martyb on Friday February 26 2021, @08:14PM   Printer-friendly

Why is the DOS path character "\"?

Many of the DOS utilities (except for command.com) were written by IBM, and they used the "/" character as the "switch" character for their utilities (the "switch" character is the character that's used to distinguish command line switches - on *nix, it's the "-" character, on most DEC operating systems (including VMS, the DECSystem-20 and DECSystem-10), it's the "/" character" (note: I'm grey on whether the "/" character came from IBM or from Microsoft - several of the original MS-DOS developers were old-hand DEC-20 developers, so it's possible that they carried it forward from their DEC background).

[...] Then along came DOS 2.0. DOS 2.0 was tied to the PC/XT, whose major feature was a 10M hard disk. IBM asked the Microsoft to add support for hard disks, and the MS-DOS developers took this as an opportunity to add support for modern file APIs - they added a whole series of handle based APIs to the system (DOS 1.0 relied on an application controlled structure called an FCB). They also had to add support for hierarchical paths.


Original Submission

This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
(1)
  • (Score: 5, Insightful) by Tork on Friday February 26 2021, @08:46PM (23 children)

    by Tork (3914) Subscriber Badge on Friday February 26 2021, @08:46PM (#1117699)
    The short version is they couldn't use the other characters/switches for fear of overloading the syntax... so they chose to overload it anyway with the same character used for escape codes. The article doesn't overtly say this but clearly this choice was about cementing Microsoft's particular brand of questionable decisions.
    --
    🏳️‍🌈 Proud Ally 🏳️‍🌈
    • (Score: 4, Insightful) by Anonymous Coward on Friday February 26 2021, @08:58PM (2 children)

      by Anonymous Coward on Friday February 26 2021, @08:58PM (#1117706)

      One of my favorite bits of MS' incompetence was that they would let you delete the current directory out from under yourself by deleting . , the result would be a consistent destruction of the entire filesystem that would require a complete reformatting. I'm not sure if there was a way of fixing the damage, but it still boggles my mind that nobody involved in QA thought about testing that.

      • (Score: 2) by Dr Spin on Saturday February 27 2021, @10:12AM (1 child)

        by Dr Spin (5239) on Saturday February 27 2021, @10:12AM (#1117890)

        it still boggles my mind that nobody involved in QA thought about testing that.

        It boggles my mind that you think MS has a QA department.

        --
        Warning: Opening your mouth may invalidate your brain!
        • (Score: 0) by Anonymous Coward on Sunday February 28 2021, @03:31PM

          by Anonymous Coward on Sunday February 28 2021, @03:31PM (#1118199)

          They used to, back when Gates ran the place.

          These days the home user is the QA via the insider program and the feedback tool.

          For all his market machniations, i miss Gates. At least he was a old school "engineer" who knew what it meant to admin a computer. Nadella appears to be the typical architecture astronaut webdev, who's mantra is CI/CD (aka push-to-prod). More accustomed to herding 1000s of "nodes" according to some platonic ideal model, isolated from the real world thanks to multiple layers of containers and VMs, than actually having to bootstrap a system from removable media and manuals.

    • (Score: 0) by Anonymous Coward on Friday February 26 2021, @09:06PM (9 children)

      by Anonymous Coward on Friday February 26 2021, @09:06PM (#1117711)

      Forward slash, back slash, close enough.
      It posed no problem except to those unix geeks who eventually had to interoperate with MS filesystems.
      Those MS filepaths make for some easy to read regular expressions, too. :^)

      • (Score: 2) by Tork on Friday February 26 2021, @09:35PM (6 children)

        by Tork (3914) Subscriber Badge on Friday February 26 2021, @09:35PM (#1117726)
        The scripting work I do involves messing around with filepaths and in order to support spaces in the filenames I end up using quotes a lot.. which requires escape codes... and well this article just reminded me that that specific decision Microsoft made has made my daily life harder for like over a decade now. Heh.

        One of the apps I use on a daily basis is notable for being cross-platform, it's available on Linux and OSX. An update for one is an update for all. One day they did an update where they use their own home-grown file-dialog instead of using the built in API. The day I stopped bitching about the needless re-inventing of the wheel was the day I found out that the dialog doesn't care which slash you use when pasting filepaths. I'm convinced this was done by a developer that was tired of sanitizing his paths before copying/pasting... like I wanna find out who that is and send them this article.
        --
        🏳️‍🌈 Proud Ally 🏳️‍🌈
        • (Score: 4, Informative) by linuxrocks123 on Friday February 26 2021, @10:11PM (5 children)

          by linuxrocks123 (2557) on Friday February 26 2021, @10:11PM (#1117737) Journal

          So, it's not widely publicized, but, from the very beginning, DOS/Windows has allowed you to use / instead of \ as the path separator, for compatibility with UNIX, in the C API. Try it and see; I'm not making that up. You can fopen("C:/Users/tork/file.txt") and it _WILL_ work.

          That won't help you copy/pasting into the standard file dialog boxes, but it is helpful for a lot of use cases.

          • (Score: 2) by Tork on Friday February 26 2021, @10:23PM (1 child)

            by Tork (3914) Subscriber Badge on Friday February 26 2021, @10:23PM (#1117739)
            Yes the scripting interpreter I'm using will accept that no problem, the issue is I sometimes run into is that I have to generate dos-friendly commands. Imagine a situation, for example, where your script generates a batch file then asks Windows to execute it. At that point you have to play by Windows' rules.

            If you're saying I'm being a whiney bitch... you're right! I'm being petty. I just find it a bit frustrating that I trip over this specific issue on a daily basis but I wouldn't have to if I used *any* other operating system. Heh. As I recall pre-OSX MacOS even used ":" instead of "\\", it was harder to write the Win version than the Mac version of that script... and that's from somebody who was using a Mac for the first time!
            --
            🏳️‍🌈 Proud Ally 🏳️‍🌈
            • (Score: 1, Informative) by Anonymous Coward on Friday February 26 2021, @10:47PM

              by Anonymous Coward on Friday February 26 2021, @10:47PM (#1117752)

              Now do VMS style: square brackets around the directories and dots between them. Oh, and angle brackets are accepted for compatibility with TOPS-10.

          • (Score: 2) by turgid on Friday February 26 2021, @10:43PM (1 child)

            by turgid (4318) Subscriber Badge on Friday February 26 2021, @10:43PM (#1117750) Journal

            The first version of MS-DOS I used was 3.3x, and not long after I started coding in C. I didn't know that you could use / as a directory separator, but I do remember their being some weirdness in DOS that meant you couldn't recourse directories without a work-around. What was that?

            • (Score: 0) by Anonymous Coward on Saturday February 27 2021, @03:13AM

              by Anonymous Coward on Saturday February 27 2021, @03:13AM (#1117822)

              I don't know if this is the one you are talking about but in early versions of DOS, to guarantee you could access something in the subdirectories of a directory, you had to recur through the entire path to the one you wanted. E.g. to access C:\A\B\C you had to open C:\ then C:\A\ then C:\A\B\ then C:\A\B\C. You could get away with not doing so if it were accessed recently or in your CWD, but going outside those was not guaranteed to succeed without doing it recursively. Thankfully they fixed that in later versions.

          • (Score: 2) by fakefuck39 on Saturday February 27 2021, @08:24AM

            by fakefuck39 (6620) on Saturday February 27 2021, @08:24AM (#1117879)

            it's even more than that. windows lets you open any resource. I believe this came for example, you can open the soylent URL in notepad. try it, and it _will_ work. as far as dialog boxes - yes, the "/" works as well. not only can you do "cd /users/fakefuck39" in cmd, but you can type in a "/" separated path into the file dialog boxes as well.

            the url thing I think came from the era of when they integrated IE and file explorer. heck, it even shows ftp sites as a drive w/ expandable directories in the gui, and you can type URLs like ftp:// and http:// into the address bar where you can type "/users"

            they just made it "location" now, instead of file, and some API layer figures out where that location is and what protocol to use to fetch the data.

      • (Score: 3, Interesting) by SDRefugee on Friday February 26 2021, @10:34PM (1 child)

        by SDRefugee (4477) on Friday February 26 2021, @10:34PM (#1117744)

        No kidding.. For 20 years, I used/supported Windows, with my use of Windows at about 95%, and 5% Linux. Now that I'm retired, I'm 99.9% Linux and 0.1% Windows and believe me, when I'm forced to use Windows, the abrupt change from forward slash to backslash is VERY jarring. Just one of the MANY MANY reasons I'm so very glad I don't have to use Windows as a daily driver.

        --
        America should be proud of Edward Snowden, the hero, whether they know it or not..
        • (Score: 3, Interesting) by stormreaver on Saturday February 27 2021, @02:16AM

          by stormreaver (5101) on Saturday February 27 2021, @02:16AM (#1117805)

          Now that I'm retired, I'm 99.9% Linux and 0.1% Windows....

          I'm very fortunate in that my job entails 99.9% Linux and 0.1% Windows, and has been that way for the last fifteen years. I foresee it being that way until I retire, at which point it will be 100% Linux. Perhaps "fortunate" isn't the right word, as I engineered the rise of Linux where I work.

    • (Score: 4, Insightful) by JoeMerchant on Friday February 26 2021, @09:51PM (1 child)

      by JoeMerchant (3937) on Friday February 26 2021, @09:51PM (#1117734)

      Well, then along come libraries like Qt where you just do as you please with / or \ and it straightens that out for you based on your runtime target.

      Still doesn't fix the case insensitivity vs case sensitive filenames.

      An idiot can screw up a bowling ball using nothing more than a plastic spoon.

      --
      🌻🌻 [google.com]
      • (Score: 0) by Anonymous Coward on Wednesday March 10 2021, @07:22AM

        by Anonymous Coward on Wednesday March 10 2021, @07:22AM (#1122173)

        Speaking as someone who has dealt with Qt ... that's not true. We finally resorted to pragmas for (external) resource location strings.

        Unless maybe it's changed since then.

    • (Score: 2) by stormreaver on Saturday February 27 2021, @04:00PM (6 children)

      by stormreaver (5101) on Saturday February 27 2021, @04:00PM (#1117954)

      Add to that shortsightedness the obviousness of the complete and total lack of conflict by using the forward slash as both the switch and the directory path. That's because, by the conventions of the time, a switch will always immediately precede a directory path (if a directory path is used by the program). And if a program doesn't have switches, but uses a directory path as arguments, using the same character for both won't matter.

      So Microsoft developers decided to destroy interoperability for such a non-issue? No, not at all. Microsoft decided to destroy interoperability in order to maintain market dominance. At that point in time, Microsoft's market dominance was not yet complete. Making its programs incompatible with the rest of the industry was a major objective, and this was just one small part of a larger plan. It worked, too, as this was more important than it seems for those who didn't live through it. People didn't want to have to deal with two separate filesystem standards, so they chose one. Since Microsoft had a congealing monopoly on the desktop, which also affected which servers would be used, most people chose the Microsoft standard. That made everything else incompatible, and furthered Microsoft's monopoly position.

      • (Score: 2) by maxwell demon on Saturday February 27 2021, @04:12PM (5 children)

        by maxwell demon (1608) on Saturday February 27 2021, @04:12PM (#1117960) Journal

        That's because, by the conventions of the time, a switch will always immediately precede a directory path

        Do you have any reference to back up this claim? Because I'm pretty sure that copy \foo\bar.baz \qux\quux.baz was a legal command since DOS 2.0 (which AFAIK was the first version of DOS to support directories).

        --
        The Tao of math: The numbers you can count are not the real numbers.
        • (Score: 0) by Anonymous Coward on Saturday February 27 2021, @04:25PM (2 children)

          by Anonymous Coward on Saturday February 27 2021, @04:25PM (#1117969)

          That's probably legal, but I don't know anybody that would have done that. Staring a directory with a \ is just bad practice, we always either just used relative paths or included the drive out of habit. The extra 2 characters didn't take that long and it helped deal with the situations where we were typing directly into the buffer and waiting for the computer to execute. If you leave off the drive and a drive change wasn't successful it could lead to issues that wouldn't happen with a full path.

          • (Score: 2) by maxwell demon on Saturday February 27 2021, @04:41PM

            by maxwell demon (1608) on Saturday February 27 2021, @04:41PM (#1117974) Journal

            That's probably legal, but I don't know anybody that would have done that.

            It doesn't matter if you know anyone who has done that. “Nobody will ever do this, so we don't have to care” is the path to nasty bugs.

            --
            The Tao of math: The numbers you can count are not the real numbers.
          • (Score: 2) by TheRaven on Sunday February 28 2021, @03:08PM

            by TheRaven (270) on Sunday February 28 2021, @03:08PM (#1118191) Journal
            It's been a long time since I used DOS, but I started things with \ a lot, unless I was explicitly operating on a different disk.
            --
            sudo mod me up
        • (Score: 2) by stormreaver on Sunday February 28 2021, @12:11AM (1 child)

          by stormreaver (5101) on Sunday February 28 2021, @12:11AM (#1118083)

          Because I'm pretty sure that copy \foo\bar.baz \qux\quux.baz was a legal command since DOS 2.0....

          Windows XP and earlier syntax

          COPY [/A | /B] source [/A | /B] [+ source [/A | /B] [+ ...]] [destination] [/A | /B]] [/V] [/Y | /-Y]

          This, like all MS-DOS commands, is easily parseable regardless of directory delimiter. This command doesn't involve a switch that alters the directory references, so it's not a great example of what I was saying in that regard. However, it is a good example of how the use of the forward slash as the directory character doesn't break anything.

          • (Score: 2) by maxwell demon on Sunday February 28 2021, @08:35AM

            by maxwell demon (1608) on Sunday February 28 2021, @08:35AM (#1118139) Journal

            This, like all MS-DOS commands, is easily parseable regardless of directory delimiter.

            Really? Then please tell me whether

            COPY /A /B /V

            should be interpreted as

            COPY /A \B \V

            or

            COPY \A /B \V

            or

            COPY \A \B /V

            or

            COPY \A \B \V

            All four commands are valid according to the syntax.

            --
            The Tao of math: The numbers you can count are not the real numbers.
    • (Score: 2) by maxwell demon on Saturday February 27 2021, @04:01PM

      by maxwell demon (1608) on Saturday February 27 2021, @04:01PM (#1117955) Journal

      so they chose to overload it anyway with the same character used for escape codes.

      The character is almost universally used for escape codes nowadays. It wasn't used as universally for that purpose back when Microsoft made that choice. In particular it wasn't used for that purpose on the DOS command line.

      --
      The Tao of math: The numbers you can count are not the real numbers.
  • (Score: 0) by Anonymous Coward on Friday February 26 2021, @08:56PM

    by Anonymous Coward on Friday February 26 2021, @08:56PM (#1117703)

    They had to use "\" because Bill Gates had reserved all the other characters for the telematics APIs.

  • (Score: 1, Insightful) by Anonymous Coward on Friday February 26 2021, @09:48PM (7 children)

    by Anonymous Coward on Friday February 26 2021, @09:48PM (#1117732)

    IIRC there was an undocumented interrupt that let allegedly allowed you to choose that path delimiter character ... it was in the interrupt list published in the big yellow book by Dr Dobbs ... can't seem to find a reference to that interrupt online but I say allegedly as it didn't work for me on the dos versions I had at the time

    • (Score: 3, Funny) by JoeMerchant on Friday February 26 2021, @10:19PM (6 children)

      by JoeMerchant (3937) on Friday February 26 2021, @10:19PM (#1117738)

      Back in the 1991-1993 timeframe it seems like a major version of DOS was coming out every 4-8 months, major enough to be "99% backwards compatible" which meant in practice: if you've got 10,000 lines of code, about 100 of them probably need tweaking to work with the new DOS.

      Lots of those undocumented features would only work on specific DOS versions.

      At the time, I got an "Error 67" in some particular situation, the printed handbook had errors up to 64, and M$ had a 1-800 support number, so I dialed and put their hold music on speakerphone - for 6 hours - before they finally got around to answering me, only to say "gee, there's no description here for Error 67." Yeah, genius, that's why I called and tied up one of your 1800 lines for 6 hours waiting for you to answer.

      --
      🌻🌻 [google.com]
      • (Score: 3, Interesting) by turgid on Friday February 26 2021, @10:37PM

        by turgid (4318) Subscriber Badge on Friday February 26 2021, @10:37PM (#1117747) Journal

        Oxygene by Jean-Michel Jarre?

      • (Score: 0) by Anonymous Coward on Friday February 26 2021, @11:57PM

        by Anonymous Coward on Friday February 26 2021, @11:57PM (#1117768)

        All that churning of the DOS pot was necessary in order that "DOS isn't done 'til Lotus won't run"!

      • (Score: 2) by aristarchus on Saturday February 27 2021, @01:33AM (1 child)

        by aristarchus (2645) on Saturday February 27 2021, @01:33AM (#1117788) Journal

        Now that is progress! I thought the error message, "There has been an undetectable error in the system" was as good as it could get. But now I find out it gets better? "There has been the undetectable and undocumented error 67 in the system."

            Not only can Microsoft not detect the error, they don't know what it is, but they do have a number for it! Brilliant!

        • (Score: 3, Interesting) by hendrikboom on Saturday February 27 2021, @07:35PM

          by hendrikboom (1125) Subscriber Badge on Saturday February 27 2021, @07:35PM (#1118007) Homepage Journal

          In the 60's error message number 999 for the IBM Fortran H compiler was for "invalid message number".
          Instead of letting me know what the invalid message number was, I got

          IEH999I INVALID MESSAGE NUMBER

          -- hendrik

      • (Score: 0) by Anonymous Coward on Saturday February 27 2021, @12:49PM (1 child)

        by Anonymous Coward on Saturday February 27 2021, @12:49PM (#1117912)

        At the time, I got an "Error 67" in some particular situation, the printed handbook had errors up to 64

        Just use Google! Geez, grandpa!

        https://www.itlnet.net/programming/program/Reference/Doserr.htm [itlnet.net]

        67. Network name not found

  • (Score: 0) by Anonymous Coward on Saturday February 27 2021, @12:02AM (2 children)

    by Anonymous Coward on Saturday February 27 2021, @12:02AM (#1117770)

    File this under "no shit."

    • (Score: 3, Funny) by Anonymous Coward on Saturday February 27 2021, @05:33AM (1 child)

      by Anonymous Coward on Saturday February 27 2021, @05:33AM (#1117854)

      Ok,
      /home/AC/no shit/this

  • (Score: 2) by mendax on Saturday February 27 2021, @05:54AM

    by mendax (2840) on Saturday February 27 2021, @05:54AM (#1117855)

    I always found the DOS/Windows backslash delimiter to be a pain in the ass because the key on the keyboard is so hard to reach when touch typing. I'll never forgive Microsoft for such a hideous decision.

    --
    It's really quite a simple choice: Life, Death, or Los Angeles.
  • (Score: 2) by Thexalon on Saturday February 27 2021, @03:33PM (1 child)

    by Thexalon (636) on Saturday February 27 2021, @03:33PM (#1117946)

    Microsoft has consistently placed a premium on backwards compatibility, even when it was stupid or even dangerous. And that's meant that stupid decisions and security problems from ages ago continue to plague us. This is just one of many examples.

    --
    The only thing that stops a bad guy with a compiler is a good guy with a compiler.
    • (Score: 0) by Anonymous Coward on Sunday February 28 2021, @10:02PM

      by Anonymous Coward on Sunday February 28 2021, @10:02PM (#1118295)

      Microsoft has consistently placed a premium on backwards compatibility

      lmao .. go paste your DOSy paths into SharePoint Online Lists and try to work out what just happened

  • (Score: 4, Informative) by stormwyrm on Saturday February 27 2021, @07:10PM

    by stormwyrm (717) on Saturday February 27 2021, @07:10PM (#1118003) Journal

    IIRC, at the time DOS was introduced there were many CP/M programs already using the forward slash character to prefix command line options, the way Unix commands generally used hyphens, so DOS likewise used the forward slash as a command line option character in order to make it easier to port CP/M programs to DOS. DOS 1.0 didn't originally have a hierarchical file system, which was added in 2.0, and they needed to use some character to act as a path separator. They couldn't use the forward slash already used by Unix-like OSes for that, so someone settled on the backslash.

    I remember that there was even an undocumented "set switchar" int 21h DOS system call that allowed you to change the command line option prefix character from the CP/M style forward slash to the Unix-style hyphen and the path separator from the regular DOS backslash to the Unix-style forward slash. You could then type something like dir -s -w -p c:/dos instead of dir /s /w /p c:\dos. Maybe they were considering altering these conventions at some point but the obligation to backwards compatibility was much too strong.

    --
    Numquam ponenda est pluralitas sine necessitate.
(1)