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

S

Stephen Ferg

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?
 
B

Ben Finney

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?
 
B

Bob Gailer

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
(e-mail address removed)
303 442 2625
 
M

Michael Geary

Stephen said:
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
 
A

Andrew Dalke

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
(e-mail address removed)
 
M

Michael Geary

Ben said:
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
 
A

Andrew Dalke

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
(e-mail address removed)
 
G

Grant Edwards

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.
 
G

Grant Edwards

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.
 
M

Michael Geary

Grant said:
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
 
J

Jules Dubois

On 25 Sep 2003 16:50:49 -0700, in article
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.
 
T

Tim Roberts

Grant Edwards said:
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.
 
A

Andrew Dalke

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
(e-mail address removed)
 
A

Alex Martelli

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.


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
 
G

Grant Edwards

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.
 
D

Duncan Booth

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.
 
R

Ronald Oussoren

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
 
P

Peter Hansen

Andrew said:
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
 
S

Stephen Horne

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.
 
R

Robin Becker

Stephen said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top