delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/06/12/04:54:05

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:message-id:from:to:subject
:content-type:date:content-transfer-encoding; q=dns; s=default; b=
aWQQDBSw+fdnWD7HYXTCHp15H2RNYnvKYHsboaWpccRfJu0TNXi02VDfkEPsec25
kxxiYJZzlrtdYPlxGxnH6YB0dlqVKMOtlEZMOw4D0dGS2QAGz0PXJS5jiJ1fwXDi
myQmryjkgHxjAvx+6M7Q8vBwHyraoiETOp4ZNQI0MNw=
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:message-id:from:to:subject
:content-type:date:content-transfer-encoding; s=default; bh=F76t
vU09RGD6yOVPEqkxIf2/OrY=; b=QncNtmpiyAqKxFW95iLn+w8r3miH+v5kPcOL
UUVrfH0irB9NdYbAfDfA2Zgg63ZlKn3+14pLRQ4gFWYXv7gYHgmipRY9FbCNniz7
WOZ4eftavXR7QZR+nIZshyIYjjm+S5O/f7VvxZKTLanObAkncvsIKg3Xu7Lkfyuh
2KAV3uk=
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=-7.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=sincerely
X-HELO: mout.gmx.net
MIME-Version: 1.0
Message-ID: <trinity-82173dac-d842-4a87-8d1f-bed9a958d178-1528793630066@3c-app-gmx-bs08>
From: "Sven Eden" <sven DOT eden AT gmx DOT de>
To: cygwin AT cygwin DOT com
Subject: Problematic interpretion of paths starting with double slashes
Date: Tue, 12 Jun 2018 10:53:50 +0200
Sensitivity: Normal
X-IsSubscribed: yes
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id w5C8s4Zw022904

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


- Raw text -


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