From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 116048 invoked by alias); 12 Jun 2018 10:01:36 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 115973 invoked by uid 89); 12 Jun 2018 10:01:28 -0000 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 Received: from mail-ot0-f194.google.com (HELO mail-ot0-f194.google.com) (74.125.82.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Jun 2018 10:01:22 +0000 Received: by mail-ot0-f194.google.com with SMTP id a5-v6so27324243otf.12 for ; Tue, 12 Jun 2018 03:01:22 -0700 (PDT) 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: In-Reply-To: From: Adam Dinwoodie Date: Tue, 12 Jun 2018 11:52:00 -0000 Message-ID: Subject: Re: Problematic interpretion of paths starting with double slashes To: cygwin@cygwin.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2018-06/txt/msg00122.txt.bz2 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 . 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 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 =E2=80=93 myself included =E2=80=93 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 , or possibly something with the mount table per . 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