delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/06/12/06:01:48

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:references:in-reply-to:from:date
:message-id:subject:to:content-type:content-transfer-encoding;
q=dns; s=default; b=c607vbq8kBAxKOZiRElBJmRYAlU/xWX4bFt/tc/LkQ1
gfLIR9jBZSwIAJcCH57p9k3fXaE/C/nDDh0gVk9AS1sm1WbOIr+QShQykZdOi2N0
Gu9SWzios/I3KunKKM2XEIsZ7s4H9Zc2E4DRk9z6k/MtRRCwZncESd+fYjS+5Z4k
=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:references:in-reply-to:from:date
:message-id:subject:to:content-type:content-transfer-encoding;
s=default; bh=rrTbPMXwK+1vZxXRN96Z1MJYq+0=; b=mSAtJzxZ89JYOGyDh
CdLgVybFIfFXKkKiuIFChPFT2bJ9MlT7dwgAbA6mLmRrlexpgHFnyOz0M58oSiFc
oBOkQGAXVg8+aqPPMj/Cb9ih2m4vQoi4C3vEAYCNowu5+9Pa3uEle+BSI18MxBSe
2I6owB6ghPaRz9UyWB20xZbFfY=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-6.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=console, states
X-HELO: mail-ot0-f194.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=1OdnYHntp/Nlpo7eAu9liHIVA2X6MTTGlDwkkZTvDJA=; b=HbxWygOBo3eGrg/laBjx6b4kdLX6HA1+0EgtMzaswCz4C31hb1XU1KxKs4IiwWs760 k9CBJ9IRbz+qh3Pi3aDwPbskYaP8cmS/5mdtd/aI94Paz082TKQqB5GNgBch6BfySomZ cbt1X+DnYzCa1Oauh0qxyRl213rlPOlIwCzxOBjs82gkI6xgTXOKQW10LZNsdNXKuDu/ l7tN3lWyPKDsqJMfpWkdof/uYr0ab3j5Zbg66THe5d0j72BBr0v/c+pPJQww6RAhYhIO igspFbY3+99B+Je/u+ZAb+eqIVyI/RHJeMGGsuvPgQSn5jhR2xF7a+o7gBU/yqmyLlyF QlMQ==
X-Gm-Message-State: APt69E2xYhz6DtbxG1rkNK9Lp8rl8mgApvhLQYG6LfpvC1G+QB/XQpgU EdFuj5GFTAATSPP9VSFGipjiTLKxAZNc1yB130qMbR14UbE=
X-Google-Smtp-Source: ADUXVKI2FbhfAK3fUqchsqOdrkhH1dkW43xM3/fKNoVD43/nwyktzoWbJ8KM4h+zgJV0uDi9WbMuAHbgHQEOMff7Th0=
X-Received: by 2002:a9d:106b:: with SMTP id o40-v6mr1975733oto.136.1528797680750; Tue, 12 Jun 2018 03:01:20 -0700 (PDT)
MIME-Version: 1.0
References: <trinity-82173dac-d842-4a87-8d1f-bed9a958d178-1528793630066 AT 3c-app-gmx-bs08>
In-Reply-To: <trinity-82173dac-d842-4a87-8d1f-bed9a958d178-1528793630066@3c-app-gmx-bs08>
From: Adam Dinwoodie <adam AT dinwoodie DOT org>
Date: Tue, 12 Jun 2018 11:00:44 +0100
Message-ID: <CA+kUOa=fAOR61hgRThYYm=vzvjbg_6utgGQVN48HpKwO4RMnzQ@mail.gmail.com>
Subject: Re: Problematic interpretion of paths starting with double slashes
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id w5CA1kFd028767

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 AT CHH0711 ~ >
> rm -rf /tmp/foo
>
> # 09:29:37 SEden AT CHH0711 ~ >
> mkdir -p /tmp/foo
>
> # 09:29:42 SEden AT CHH0711 ~ >
> touch /tmp/foo/bar
>
> # 09:29:59 SEden AT 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


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019