Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why does "cd /usr/////bin" = "cd /usr/bin"?

42 views
Skip to first unread message

Brett J. Heroux

unread,
Sep 18, 1991, 10:32:22 PM9/18/91
to
This created $HOME/filename !?

date > $HOME///////filename

No common sense reason for this has occurred to me.

(no mail through newsreader, her...@horus.cem.msu.edu)

D'Arcy J.M. Cain

unread,
Sep 19, 1991, 11:27:29 PM9/19/91
to
her...@cemmva.cem.msu.edu (Brett J. Heroux) writes:
>This created $HOME/filename !?
>date > $HOME///////filename
>No common sense reason for this has occurred to me.

It means that your programs can do things like:

printf(Enter directory name: ");
gets(file_name);
strcat(file_name, "/basename");

Whereas in DOS you wind up doing:

printf(Enter directory name: ");
gets(file_name);
if (file_name[strlen(file_name) - 1] == '\\')
strcat(file_name, "basename");
else
strcat(file_name, "\\basename");

Actually it's worse since both slash and backslash are acceptable so you
really have to test for both.

If directory separators didn't collapse then what would "$HOME/////filename"
mean?


--
D'Arcy J.M. Cain (darcy@druid) |
D'Arcy Cain Consulting | There's no government
Toronto, Ontario, Canada | like no government!
+1 416 424 2871 DoD#0082 |

Jeff Beadles

unread,
Sep 20, 1991, 7:28:37 PM9/20/91
to
her...@cemmva.cem.msu.edu (Brett J. Heroux) writes:

>This created $HOME/filename !?
>date > $HOME///////filename
>No common sense reason for this has occurred to me.

Well, in the typical unix tradition, this has mutated into
date > $HOME/././././././filename

However, most of the kernel's that I have seen all strip multiple '/' within
the middle of a pathname.

Several versions of "unix" treat leading double shashes "//foo" as a special
case. Examples of these are Domain OS (Apollo) and older versions of UTek
(Tektronix, rip)

-Jeff
--
Jeff Beadles je...@onion.rain.com

James Risner

unread,
Sep 21, 1991, 7:09:57 PM9/21/91
to
je...@onion.rain.com (Jeff Beadles) writes:
>Several versions of "unix" treat leading double shashes "//foo" as a special
>case. Examples of these are Domain OS (Apollo) and older versions of UTek
>(Tektronix, rip)

I am rather curious as to what special case "//foo" would signal?

James Risner

Dr. Peter Lipp

unread,
Sep 20, 1991, 2:43:54 AM9/20/91
to
In article <0094ED90...@cemmva.cem.msu.edu>, her...@cemmva.cem.msu.edu (Brett J. Heroux) says:
>
>This created $HOME/filename !?
>
>date > $HOME///////filename
>
>No common sense reason for this has occurred to me.
>
WHAT did you expect anyway? Anything else happening would make less sense
I think, except may be an error message.

Peter

Jim Williams

unread,
Sep 24, 1991, 10:08:29 AM9/24/91
to
The Posix standard (see sections 2.3 and 2.4) requires that multiple
slashes in a pathname be interpreted as a single slash. The one
exception to this is when the path begins with slash. In that one
case, is it permitted for an implementation to give special meaning to
a pathname that begins with exactly two slashes. This is how some
Unixes implement remote file systems. For example,
//remotehost/usr/local/foo might be the file /usr/local/foo on the
machine named remotehost. Any other use of multiple slashes, such as
////remotehost/usr/local/foo or /usr////////////local/foo must be
treated as though there were one slash.

This behavior is reasonable and desirable. On more than one
occasion, I've used a command such as

% mv f1 foo/bar/baz # baz is a directory, so file will be foo/bar/baz/f1

to move a file into a new directory without changing it's name.
Now, if I do this and misspell "baz", then instead of putting the
file in the directory foo/bar/baz, I end up with a file named
foo/bar/bax, or something like that. After doing this enough times,
I've gotten in the habbit of ALWAYS putting a slash at the end of
directory names in such cases.

% mv f1 foo/bar/baz/

Now if I misspell baz, the mv will fail, since the directory
foo/bar/bax doesn't exist. When I do spell baz correctly, mv almost
surely generates the target pathname internally as foo/bar/baz//f1,
so this trick of mine will only work if multiple slashes are treated
sensibly. This does NOT work under DOS...

% COPY F1.C SOURCE\

will barf. Stupid DOS.

Jim
--
Spoken: James W. Williams Internet: will...@nssdcs.gsfc.nasa.gov
USPS: NASA/Goddard SFC; Code 933; Greenbelt, MD 20771
Phone: +1 301 286-1131 Maryland Car Tags: DEV CAR
Motto: There is no 'd' in "kluge"! It rhymes with "huge", not "sludge"!

Guy Harris

unread,
Sep 24, 1991, 2:02:00 PM9/24/91
to
>I am rather curious as to what special case "//foo" would signal?

In Domain/OS and, I think, some other systems, "//foo/bar" was "file
named 'bar' in the root directory of the machine named 'foo'".

Dan Flak

unread,
Sep 23, 1991, 2:50:45 PM9/23/91
to

The double slash in UTek means a host on the same network with
you. So, it means that you can

cp *.c //r2d2/usr/local/src/foo.

to copy files from wherever you are to /usr/local/src/foo
on host, r2d2. You can also:

cd //r2d2/usr/users/foo

and

//c3p0/usr/local/bin/ispell foobar.
--
Dan Flak - Just another idiot, born in the USA and over 35.

0 new messages