public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Problematic interpretion of paths starting with double slashes
@ 2018-06-12 11:45 Sven Eden
  2018-06-12 11:52 ` Adam Dinwoodie
  2018-06-12 16:28 ` Eric Blake
  0 siblings, 2 replies; 16+ messages in thread
From: Sven Eden @ 2018-06-12 11:45 UTC (permalink / raw)
  To: cygwin

Hello everybody,
 
I have a problem with a script that wants to copy a file,
which has a variable paths build from various variables.

The first variable is a possible prefix, the second an
absolute path. If no prefix is needed, the first consists of
just a slash.

What I now see is the following:

--------
# 09:29:17 SEden@CHH0711 ~ >
rm -rf /tmp/foo

# 09:29:37 SEden@CHH0711 ~ >
mkdir -p /tmp/foo

# 09:29:42 SEden@CHH0711 ~ >
touch /tmp/foo/bar

# 09:29:59 SEden@CHH0711 ~ >
cp //tmp/foo/bar /tmp/foo/baz
cp: cannot stat '//tmp/foo/bar': No such file or directory
--------

This puzzled me, because this works perfectly well on every
GNU/Linux (plus WSL) system I tried. Actually it is
completely in order to double any slashes.
This behavior breaks quite some Makefiles...

I am completely aware that §4.13 of the Open Group Base
Specification Issue 7 (IEEE Std 1003.1-2017) reads:
    "If a pathname begins with two successive <slash>
     characters, the first component following the leading
     <slash> characters may be interpreted in an
     implementation-defined manner, although more than two
     leading <slash> characters shall be treated as a single
     <slash> character."

My question therefore is, whether the behavior can be gotten
nearer what every other GNU/Linux system does.
Maybe, if said first component can not be resolved as an smb
host, try an absolute path instead?

On any Linux system, 'stat -c "%i" / //' would
show the same inode number twice:
--------
stat -c "%2n %f %i" / //
 / 41ed 48976645948727610
// 41ed 48976645948727610
--------

On Cygwin we get:
--------
stat -c "%2n %f %i" / //
 / 41ed 4222124652325260
// 416d 18014896789143535314
--------

I have searched the cygwin mailing list, but all I could find
was some discussion about UNC paths from 1997.


So, what do you think?


Sincerely

Sven


P.S An example of a failing script line is:
https://github.com/gentoo/gentoo/blob/331976f/eclass/toolchain.eclass#L2136

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2018-06-14 17:41 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12 11:45 Problematic interpretion of paths starting with double slashes Sven Eden
2018-06-12 11:52 ` Adam Dinwoodie
2018-06-12 16:28 ` Eric Blake
2018-06-12 17:12   ` Aw: " Sven Eden
2018-06-12 17:57     ` Brian Inglis
2018-06-13 10:14       ` Aw: " Sven Eden
2018-06-13 13:49         ` Andrey Repin
2018-06-15  2:41         ` Brian Inglis
2018-06-12 20:01     ` Aw: " Eric Blake
2018-06-13 13:05       ` Sven Eden
2018-06-12 20:32     ` Lee
2018-06-13 13:05       ` Aw: " Sven Eden
2018-06-12 23:31     ` Aw: " Achim Gratz
2018-06-13  9:57       ` Corinna Vinschen
2018-06-13 13:29         ` Sven Eden
2018-06-13 19:32           ` Achim Gratz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).