When did Windows start accepting forward slash as a path separator?

Discussion in 'Python' started by Stephen Ferg, Sep 26, 2003.

  1. Stephen Ferg

    Stephen Ferg Guest

    I have a question that is not directly Python-related. But I thought
    I'd ask the most erudite group that I know... :)

    When did Windows start accepting the forward slash as a path separator
    character?

    At one time, it was accepted as a truism that Windows (like MS-DOS)
    was different from Unix because Windows used the backslash as the path
    separator character, whereas Unix used the forward slash.

    But now, among a small group of cognoscenti, it is a truism that this
    is a myth, and that Windows will allow you to use either the forward
    or the backward slash as a pathname separator.

    I hypothesize that originally Windows accepted only the backslash, and
    then at some time it changed to accept the forward slash as well.
    Does anyone know when that change occurred? Was it with the
    introduction of support for long filenames in NT and Win95?
    Stephen Ferg, Sep 26, 2003
    #1
    1. Advertising

  2. Stephen Ferg

    Ben Finney Guest

    On 25 Sep 2003 16:50:49 -0700, Stephen Ferg wrote:
    > But now, among a small group of cognoscenti, it is a truism that this
    > is a myth, and that Windows will allow you to use either the forward
    > or the backward slash as a pathname separator.


    I highly doubt it, since the forward slash (or just "slash") is the
    conventional Windows command-line option indicator, analogous to the
    hyphen on Unix. To accept it as the start of a filename would break
    zillions of existing systems, for no appreciable benefit to Microsoft.

    Python automagically determines the path component separator, os.sep,
    and uses it for most file path transformations to and from the internal
    language's '/'.

    <http://www.python.org/doc/2.3.1/lib/os-path.html#l2h-1552>

    Is this perhaps what gives you the impression?

    --
    \ "I went to a restaurant that serves 'breakfast at any time'. So |
    `\ I ordered French Toast during the Renaissance." -- Steven |
    _o__) Wright |
    Ben Finney <http://bignose.squidly.org/>
    Ben Finney, Sep 26, 2003
    #2
    1. Advertising

  3. Stephen Ferg

    Bob Gailer Guest

    Re: When did Windows start accepting forward slash as a pathseparator?

    At 05:50 PM 9/25/2003, Stephen Ferg wrote:

    >I have a question that is not directly Python-related. But I thought
    >I'd ask the most erudite group that I know... :)
    >
    >When did Windows start accepting the forward slash as a path separator
    >character?


    Good question. Certainly later than:

    Microsoft Windows 2000 [Version 5.00.2195]
    (C) Copyright 1985-2000 Microsoft Corp.

    C:\>cd /samis
    The syntax of the command is incorrect.

    Bob Gailer

    303 442 2625


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.506 / Virus Database: 303 - Release Date: 8/1/2003
    Bob Gailer, Sep 26, 2003
    #3
  4. Stephen Ferg wrote:
    > When did Windows start accepting the forward slash as a path separator
    > character?
    >
    > At one time, it was accepted as a truism that Windows (like MS-DOS)
    > was different from Unix because Windows used the backslash as the path
    > separator character, whereas Unix used the forward slash.
    >
    > But now, among a small group of cognoscenti, it is a truism that this
    > is a myth, and that Windows will allow you to use either the forward
    > or the backward slash as a pathname separator.
    >
    > I hypothesize that originally Windows accepted only the backslash, and
    > then at some time it changed to accept the forward slash as well.
    > Does anyone know when that change occurred? Was it with the
    > introduction of support for long filenames in NT and Win95?


    Hi Steve,

    Every version of Windows has accepted "/" as a path separator. So has every
    version of MS-DOS beginning with DOS 2.0 (the first version that had
    subdirectories).

    It's only been in command lines that "/" was not allowed, because it had
    already been used as a switch delimiter in MS-DOS 1.0.

    -Mike
    Michael Geary, Sep 26, 2003
    #4
  5. Stephen Ferg

    Andrew Dalke Guest

    Stephen Ferg:
    > When did Windows start accepting the forward slash as a path separator
    > character?


    DOS 2. When directories were introduced. Many of the functions
    were based on unix, down to a NUL terminated filename and the
    name "creat".

    But DOS 1 was modelled on CP/M which used "/" as a command
    line option flag. You couldn't use a "/" in the DOS shell because
    it would be interpreted as the flag. You could change the flag using
    a DOS command, eg, to use "-" instead, but that was disabled in
    the 3.x days; for good reason.

    Hence, the low-level DOS commands (since 2.0) would take
    both / and \ as separators, but some codes did their own
    filename munging and would not.

    > At one time, it was accepted as a truism that Windows (like MS-DOS)
    > was different from Unix because Windows used the backslash as the path
    > separator character, whereas Unix used the forward slash.


    It was? My copy of Norton's Guide to the IBM PC makes
    the explicit statement that directories were directly influenced by
    unix. I actually regard this as a point of similarity. The character
    used is a minor issue.

    There are, of course, many ways in which they are different. Like
    drive names, which comes from CP/M, and the filesystem layout
    itself (FAT vs. inodes). And DOS had much better IDEs, like
    Turbo Pascal. ;)

    > I hypothesize that originally Windows accepted only the backslash, and
    > then at some time it changed to accept the forward slash as well.
    > Does anyone know when that change occurred? Was it with the
    > introduction of support for long filenames in NT and Win95?


    The original Windows was a shell on top of DOS. Programs
    under Windows could use the DOS layer directly, which took
    both separators. Even in Wn95 I could exit to DOS, meaning
    I could quite out of Win95 to the shell prompt then do 'win'
    to start it up again.

    Andrew
    Andrew Dalke, Sep 26, 2003
    #5
  6. > Stephen Ferg wrote:
    > > But now, among a small group of cognoscenti, it is a truism that this
    > > is a myth, and that Windows will allow you to use either the forward
    > > or the backward slash as a pathname separator.


    Ben Finney wrote:
    > I highly doubt it, since the forward slash (or just "slash") is the
    > conventional Windows command-line option indicator, analogous to the
    > hyphen on Unix. To accept it as the start of a filename would break
    > zillions of existing systems, for no appreciable benefit to Microsoft.


    Actually, every version of Windows, and every version of MS-DOS from 2.0 on,
    has accepted "/" as a path delimiter.

    Don't confuse the command line with the Windows or DOS kernel. Most command
    lines don't allow "/" because it conflicts with the use of "/" for a switch
    deliminer. But the Windows and DOS kernels are happy with either "\" or "/".

    -Mike
    Michael Geary, Sep 26, 2003
    #6
  7. Stephen Ferg

    Andrew Dalke Guest

    Re: When did Windows start accepting forward slash as a path separator?

    Bob Gailer:
    > Good question. Certainly later than:
    >
    > Microsoft Windows 2000 [Version 5.00.2195]
    > (C) Copyright 1985-2000 Microsoft Corp.
    >
    > C:\>cd /samis
    > The syntax of the command is incorrect.


    The shell is parsing the line and interprets the "/" as a
    command-line flag, Try a relative path, like

    cd ./samis

    Andrew
    Andrew Dalke, Sep 26, 2003
    #7
  8. In article <>, Stephen Ferg wrote:

    > When did Windows start accepting the forward slash as a path separator
    > character?


    Sometime prior to 1983. DOS has always accepted it, and I assume Windows
    always has as well.

    > At one time, it was accepted as a truism that Windows (like MS-DOS)
    > was different from Unix because Windows used the backslash as the path
    > separator character,


    Accepted as a truism by whom? DOS would accept either. The shell's "switch"
    character was configurable as well -- it defaulted to '/' but changing it to
    '-' was trivial.

    > whereas Unix used the forward slash.


    > But now, among a small group of cognoscenti, it is a truism that this
    > is a myth, and that Windows will allow you to use either the forward
    > or the backward slash as a pathname separator.


    I don't remember if the actual DOS system calls accepted '/' or if the C
    library translated. I do know that DOS C programs could use '/' for path
    separator at least 20 years ago.

    > I hypothesize that originally Windows accepted only the backslash, and then
    > at some time it changed to accept the forward slash as well.


    Nope. AFAIK, it's always accepted '/'. I did C programming on DOS for
    years, and I always used '/' since it was too error working with string
    literals in C that contain '\'. Those same programs seemed to run fine
    under Windows.

    > Does anyone know when that change occurred? Was it with the introduction of
    > support for long filenames in NT and Win95?


    I'm not aware that there has ever been a "change". '/' has been OK since
    the early DOS days.

    --
    Grant Edwards grante Yow! WHOA!! Ken and
    at Barbie are having TOO
    visi.com MUCH FUN!! It must be the
    NEGATIVE IONS!!
    Grant Edwards, Sep 26, 2003
    #8
  9. In article <>, Ben Finney wrote:

    >> But now, among a small group of cognoscenti, it is a truism that this is a
    >> myth, and that Windows will allow you to use either the forward or the
    >> backward slash as a pathname separator.

    >
    > I highly doubt it, since the forward slash (or just "slash") is the
    > conventional Windows command-line option indicator,


    That was configurable back in the DOS days. There was a "well-known" byte in
    system RAM that contained the "switch" character. IIRC, DOS even shipped
    with a utility to change that value.

    > analogous to the hyphen on Unix. To accept it as the start of a filename
    > would break zillions of existing systems, for no appreciable benefit to
    > Microsoft.


    Forward slashes always worked fine for me.

    > Python automagically determines the path component separator, os.sep,
    > and uses it for most file path transformations to and from the internal
    > language's '/'.
    >
    > <http://www.python.org/doc/2.3.1/lib/os-path.html#l2h-1552>
    >
    > Is this perhaps what gives you the impression?


    Forward slashes work in C as well.

    --
    Grant Edwards grante Yow! Yow! It's some people
    at inside the wall! This is
    visi.com better than mopping!
    Grant Edwards, Sep 26, 2003
    #9
  10. Grant Edwards wrote:
    > I don't remember if the actual DOS system calls accepted '/' or if
    > the C library translated. I do know that DOS C programs could
    > use '/' for path separator at least 20 years ago.


    It was the DOS system calls.

    -Mike
    Michael Geary, Sep 26, 2003
    #10
  11. Stephen Ferg

    Jules Dubois Guest

    On 25 Sep 2003 16:50:49 -0700, in article
    <>, Stephen Ferg wrote:

    > When did Windows start accepting the forward slash as a path separator
    > character?


    Even MS-DOS 3.3 would accept '/'; the command-line utilities were
    programmed to use only '\' without some start-up parameter (PATHSEP?).
    Microsoft removed that feature in v4.0 or 5.0. The "kernel" didn't care.

    The Windows kernels are the same. The internals of the operating system
    accept either.
    Jules Dubois, Sep 26, 2003
    #11
  12. Stephen Ferg

    Tim Roberts Guest

    Grant Edwards <> wrote:
    >
    >Ben Finney wrote:
    >
    >>> But now, among a small group of cognoscenti, it is a truism that this is a
    >>> myth, and that Windows will allow you to use either the forward or the
    >>> backward slash as a pathname separator.

    >>
    >> I highly doubt it, since the forward slash (or just "slash") is the
    >> conventional Windows command-line option indicator,

    >
    >That was configurable back in the DOS days. There was a "well-known" byte in
    >system RAM that contained the "switch" character. IIRC, DOS even shipped
    >with a utility to change that value.


    Yes, indeed. There was a SWITCHAR option in config.sys, and a
    corresponding DOS service, until DOS 3.0, when it was removed because they
    couldn't make it work with network software.

    So, the situation can be summed up rather simply:

    * All DOS services since DOS 2.0 and all Windows APIs accept either
    forward slash or backslash. Always have.

    * None of the standard command shells (CMD or COMMAND) will accept
    forward slashes. Even the "cd ./tmp" example given in a previous post
    fails.
    --
    - Tim Roberts,
    Providenza & Boekelheide, Inc.
    Tim Roberts, Sep 26, 2003
    #12
  13. Stephen Ferg

    Andrew Dalke Guest

    Tim Roberts:
    > * None of the standard command shells (CMD or COMMAND) will accept
    > forward slashes. Even the "cd ./tmp" example given in a previous post
    > fails.


    Yup. I should have copy&pasted rather than just type it in.
    It should have been in quotes. The following does work for me

    E:\dalke>cd ..

    E:\>cd /dalke
    The system cannot find the path specified.

    E:\>cd ./dalke

    E:\>cd "./dalke"

    E:\dalke>ver

    Windows NT Version 4.0

    E:\dalke>

    Andrew
    Andrew Dalke, Sep 26, 2003
    #13
  14. Grant Edwards wrote:
    ...
    > Nope. AFAIK, it's always accepted '/'. I did C programming on DOS for
    > years, and I always used '/' since it was too error working with string
    > literals in C that contain '\'. Those same programs seemed to run fine
    > under Windows.
    >
    >> Does anyone know when that change occurred? Was it with the introduction
    >> of support for long filenames in NT and Win95?

    >
    > I'm not aware that there has ever been a "change". '/' has been OK since
    > the early DOS days.


    I _think_ (can't be sure...) that at a C-libraries level the switch
    occurred either between DOS 1.0 and 1.1, or at the time of release of
    2.0. It's hard to say, because MS didn't release a C compiler as a
    product back then; however, it seems that, internally, they used C
    compilers running on their Unix machines (presumably their own version
    of Unix, named Xenix, which they later sold to SCO) to generate some
    parts of the DOS stuff of that age. The original QDOS ("Quick and
    Dirty OS") that they bought out and resold as DOS 1.0 surely had no
    knowledge of forward slashes -- it was basically CP/M disassembled,
    hacked and reassembled (all quite illegally of course). Just as surely,
    DOS 2.0 had that knowledge (Allen had also hacked into it some Unix
    idioms such as I/O redirection and pipes -- some "pipes", redirecting
    to a temporary file and then back out of it!, but syntactically Unixoid --
    and more generally made it an uneasy mixmash of some concepts and
    practice from the CP/M world plus a little from Unix traditions); and
    so did the first C compiler, self-hosted on DOS, that MS later sold to
    the public (having bought it, I believe, from Lattice).


    Alex
    Alex Martelli, Sep 26, 2003
    #14
  15. In article <GpScb.123559$>, Alex Martelli wrote:

    >>> Does anyone know when that change occurred? Was it with the introduction
    >>> of support for long filenames in NT and Win95?

    >>
    >> I'm not aware that there has ever been a "change". '/' has been OK since
    >> the early DOS days.

    >
    > I _think_ (can't be sure...) that at a C-libraries level the switch
    > occurred either between DOS 1.0 and 1.1, or at the time of release of
    > 2.0.


    I don't think 1.0 had a hierarchical filesystem at all did it?

    IIRC, it was basically the same as CP/M 2.2 and had nothing other than a
    "root" directory on each floppy [IIRC, CP/M 3.x had some concept of multiple
    directories on a floppy but it wasn't a tree structured FS with "paths" --
    it was more like partitioning a floppy into multiple drive letters.]

    By the time I got my hands on IBM machines 2.x was in common use, so I only
    had a brief exposure to 1.x.

    --
    Grant Edwards grante Yow! .. I want to perform
    at cranial activities with
    visi.com Tuesday Weld!!
    Grant Edwards, Sep 26, 2003
    #15
  16. Stephen Ferg

    Duncan Booth Guest

    Grant Edwards <> wrote in
    news::

    >> I _think_ (can't be sure...) that at a C-libraries level the switch
    >> occurred either between DOS 1.0 and 1.1, or at the time of release of
    >> 2.0.

    >
    > I don't think 1.0 had a hierarchical filesystem at all did it?


    That is correct, originally DOS like CP/M didn't have a concept of
    directories, all file access used file control blocks. When they added
    directories in Dos 2.0 they added new int21 calls which supported the
    directory paths and these have always accepted either forward or reversed
    slashes as path separators interchangeably.

    Dos 3.0 added an int21 call to canonicalize pathnames which included
    converting all forward slashes to backslashes.

    --
    Duncan Booth
    int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
    "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
    Duncan Booth, Sep 26, 2003
    #16
  17. On 26 sep 2003, at 5:50, Jules Dubois wrote:
    >
    > The Windows kernels are the same. The internals of the operating
    > system
    > accept either.
    >

    That's not entirely true, in WinNT derivatives the backslash is the
    real seperator at the kernel level, the Win32 perform some conversion
    that allows forward slashes and recognizes special files like CON, PRN,
    et.al..

    To make live even more interesting, only unicode paths with backslashes
    as seperators can address all files (at least when I last looked at it
    about 2 years ago). When using unicodepaths you can use '\\?\' as a
    prefix on paths to turn off the conversion I mention above (see
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/
    fileio/base/naming_a_file.asp). The fun you can have on windows, I've
    managed to create files that cannot be removed :)

    Ronald
    Ronald Oussoren, Sep 26, 2003
    #17
  18. Stephen Ferg

    Peter Hansen Guest

    Re: When did Windows start accepting forward slash as a path separator?

    Andrew Dalke wrote:
    >
    > Bob Gailer:
    > > Good question. Certainly later than:
    > >
    > > Microsoft Windows 2000 [Version 5.00.2195]
    > > (C) Copyright 1985-2000 Microsoft Corp.
    > >
    > > C:\>cd /samis
    > > The syntax of the command is incorrect.

    >
    > The shell is parsing the line and interprets the "/" as a
    > command-line flag, Try a relative path, like
    >
    > cd ./samis


    And of course, there's always:

    C:\>ver
    Windows 98 [Version 4.10.2222]

    C:\>cd ./temp
    Too many parameters - /TEMP

    C:\>cd ./temp"
    Too many parameters - /TEMP"

    C:\>cd "./temp"

    C:\>


    But I digress... *you* guys were talking about operating systems. ;-)

    -Peter
    Peter Hansen, Sep 26, 2003
    #18
  19. Re: When did Windows start accepting forward slash as a path separator?

    On Fri, 26 Sep 2003 02:05:50 GMT, "Andrew Dalke"
    <> wrote:

    >Bob Gailer:
    >> Good question. Certainly later than:
    >>
    >> Microsoft Windows 2000 [Version 5.00.2195]
    >> (C) Copyright 1985-2000 Microsoft Corp.
    >>
    >> C:\>cd /samis
    >> The syntax of the command is incorrect.

    >
    >The shell is parsing the line and interprets the "/" as a
    >command-line flag, Try a relative path, like
    >
    > cd ./samis


    Nope...

    F:\>cd ./dev

    F:\>cd .\dev

    F:\Dev>


    Notice how the forward slash version doesn't change directories, but
    the back slash version does. My guess is that it is being taken as...

    cd . /<unknown option>

    The big question being why the unknown option doesn't get an error
    message, as it normally does.


    --
    Steve Horne

    steve at ninereeds dot fsnet dot co dot uk
    Stephen Horne, Sep 26, 2003
    #19
  20. Stephen Ferg

    Robin Becker Guest

    In article <>, Stephen
    Ferg <> writes
    >I have a question that is not directly Python-related. But I thought
    >I'd ask the most erudite group that I know... :)
    >
    >When did Windows start accepting the forward slash as a path separator
    >character?
    >
    >At one time, it was accepted as a truism that Windows (like MS-DOS)
    >was different from Unix because Windows used the backslash as the path
    >separator character, whereas Unix used the forward slash.
    >
    >But now, among a small group of cognoscenti, it is a truism that this
    >is a myth, and that Windows will allow you to use either the forward
    >or the backward slash as a pathname separator.
    >
    >I hypothesize that originally Windows accepted only the backslash, and
    >then at some time it changed to accept the forward slash as well.
    >Does anyone know when that change occurred? Was it with the
    >introduction of support for long filenames in NT and Win95?


    I seem to remember getting an early C compiler from M$ around 1983/5 and
    being pleasantly surprised that '/' was acceptable. So far as I know
    this has been true from the earliest days. I suspect it was because of
    all the unix C code that people wanted to work without effort.
    --
    Robin Becker
    Robin Becker, Sep 26, 2003
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. xyZed
    Replies:
    3
    Views:
    2,053
    Toby Inkster
    Mar 4, 2006
  2. Greg Collins [Microsoft MVP]

    Links to https fails 404 with preceding forward slash

    Greg Collins [Microsoft MVP], Jun 14, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    426
    Greg Collins [Microsoft MVP]
    Jun 15, 2006
  3. Tony Meyer
    Replies:
    1
    Views:
    623
    Stephen Horne
    Sep 26, 2003
  4. destroooooy
    Replies:
    4
    Views:
    645
    Arnaud Delobelle
    Apr 29, 2008
  5. harryos
    Replies:
    2
    Views:
    1,693
Loading...

Share This Page