public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Adam Dinwoodie <adam@dinwoodie.org>
To: cygwin@cygwin.com
Subject: Re: Problematic interpretion of paths starting with double slashes
Date: Tue, 12 Jun 2018 11:52:00 -0000	[thread overview]
Message-ID: <CA+kUOa=fAOR61hgRThYYm=vzvjbg_6utgGQVN48HpKwO4RMnzQ@mail.gmail.com> (raw)
In-Reply-To: <trinity-82173dac-d842-4a87-8d1f-bed9a958d178-1528793630066@3c-app-gmx-bs08>

On Tue, 12 Jun 2018 at 09:53, Sven Eden wrote:
> 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 is intended behaviour. Cygwin interprets paths starting with //
as being attempts to access a UNC path; //tmp/foo/bar is an attempt to
access the file/directory "bar" in the "foo" share on the networked
machine "tmp", in the same way as attempting to access \\tmp\foo\bar
from a Windows cmd console or similar. This is documented at
<https://cygwin.com/cygwin-ug-net/using.html#unc-paths>.

Here, Cygwin isn't attempting to emulate Linux, which, as you note,
generally considers a double forward slash at the start of a path as
identical to a single slash. Instead, Cygwin, like Linux, is an
implementation of the POSIX standards. POSIX states "A pathname that
begins with two successive slashes may be interpreted in an
implementation-defined manner", so Cygwin is being POSIX-compliant
here, per <http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11>

I think it's very unlikely Cygwin is going to change its behaviour
here; this is documented and well-understood behaviour that other
Cygwin users – myself included – are going to be relying on. If you
want to be able to use your scripts on Cygwin as well as Linux
systems, you'll need to update them to not rely on
implementation-specific behaviour that can vary between POSIX
implementations.

(I could believe you could get buy-in for ways to change the //
behaviour that wouldn't change behaviour for existing users, e.g. by
basing it on setting the CYGWIN environment variable per
<https://cygwin.com/cygwin-ug-net/using-cygwinenv.html>, or possibly
something with the mount table per
<https://cygwin.com/cygwin-ug-net/using.html#using-pathnames>. However
I've no idea whether that would be possible without unacceptable
compromises to performance or similar, and as ever someone has to
volunteer the time to do it.)

Adam

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

  reply	other threads:[~2018-06-12 10:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-12 11:45 Sven Eden
2018-06-12 11:52 ` Adam Dinwoodie [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+kUOa=fAOR61hgRThYYm=vzvjbg_6utgGQVN48HpKwO4RMnzQ@mail.gmail.com' \
    --to=adam@dinwoodie.org \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).