From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 814 invoked from network); 15 Nov 2021 08:45:07 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 15 Nov 2021 08:45:07 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1636965907; b=pNR5Z7uL0N/36hRRu09p/xPnET+ZfmOvRsv+6IbmrNymNC14krl583lwN1ESB5JQYXsWS7rnsg 7jIs6KqQBAEc18BT03CImHaTWkjgm9zK8dffiEdg+HtanHj/lA+zTgf3DELfY6xpH+EKhpXAJX FOpZWxZNjDOIImrT0nw+WEve5Vh+U066w7PvqBrk90BXS/+1I/hJDUmksp99EhT61KTjHNsc9J 4MYzUpLOxDpeddnJwtxfsM0qPDLKkL8EeLR8y/6trTy/5Jd4bUpToCmj0YsXdWw009xFy+rClW i5IKgsiU2k1KJQkotSf1gsmVDUQyci/qVQsNJgrwgrEEZQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (snd01014-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.30; dmarc=none header.from=kba.biglobe.ne.jp; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1636965907; bh=tNCLZYCkPfvDG3V8n6gtH/rQMsPNb8vy3lSKKlF4NAM=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Message-ID:In-Reply-To:To:References:Date:Subject: MIME-Version:Content-Transfer-Encoding:Content-Type:From:DKIM-Signature; b=NYafy+vUb7Z4fBQPIlWcRvCXLHUmQdkAjA55knGqLPK2YJevCvb18FEPOk+Rq+ST5cuDiTtP+d Af2uMKJeOavUMw08mCZsfmfjbGmwHOhqNB6rP2XAv3GFs0Uk8u75F1hvORG/c9CKf8RXGcdm5Z oT31J5O4Pf7jphAQdxTSzujIbXtbQ9E1zX0zOisy7OGPx6ONQNaukNUbdk+jhB9AedxzjkLTXJ KDZCkWOoPpFyjB73tzUwk/0aZR6Bk8ZdYYVfq2BSTxMj6PgLVbm1VWWSserRZ4v9uSi8w8y4Qm jin5Q01cw0J9im5MRGVjHUtaaA9vgGw/N5Q8AYEarteivw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-Id:In-Reply-To:To:References: Date:Subject:Mime-Version:Content-Transfer-Encoding:Content-Type:From: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=DYlsR1Nk5XeHV3LvgPeje+nYDeWVhlb+LRmPJr5to9c=; b=UH6BTtPrDXVcj/2VMs0sPBGaPO IOEiJw7PEnX063o4Db3Sgjfki8//SxiAG+y1Y5MHjPSkvY04AWdLalRMKA867YCRX/ZLAm+/7QnHo BRHpXWc2IwCeeMHK7ZecaxxsidMnwODymZFKRvdnLWqWrOK8bPMXEeQ9RprCYq3btmPs7Hk2Qzczm U9Rj7PjYpdkAnfxW1Ur3OaMGmKf/MT7C2JSs/rsbIJn76AewEwNXwl7+hxZckrSImFpEAKy6rKRia 5BhTEv4ZBogWjNAdGcKq+WkLfaaxFB0xnmFNLdLDJWP0jVgBm92k8hzkoDZJL9wx0LSb2lMlI1V6v zg1L4D2A==; Received: from authenticated user by zero.zsh.org with local id 1mmXbq-000PSM-SZ; Mon, 15 Nov 2021 08:45:02 +0000 Authentication-Results: zsh.org; iprev=pass (snd01014-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.30; dmarc=none header.from=kba.biglobe.ne.jp; arc=none Received: from snd01014-bg.im.kddi.ne.jp ([27.86.113.30]:11937 helo=dfmta1013.biglobe.ne.jp) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mmXbb-000PC8-UY; Mon, 15 Nov 2021 08:44:49 +0000 Received: from mail.biglobe.ne.jp by omta1013.biglobe.ne.jp with ESMTP id <20211115084441199.GMYC.86401.mail.biglobe.ne.jp@biglobe.ne.jp> for ; Mon, 15 Nov 2021 17:44:41 +0900 From: Jun T Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: Re: Cygwin/MSYS2: Trouble converting relative paths from / using :a or :A Date: Mon, 15 Nov 2021 17:44:40 +0900 References: <01fa01d7d7fa$33567960$9a036c20$@gmail.com> To: zsh-workers@zsh.org In-Reply-To: <01fa01d7d7fa$33567960$9a036c20$@gmail.com> Message-Id: X-Mailer: Apple Mail (2.3445.104.21) X-Biglobe-Sender: takimoto-j@kba.biglobe.ne.jp X-Seq: 49586 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: > 2021/11/13 4:19, agkozak@gmail.com wrote: >=20 > In Cygwin or MSYS2, if I execute > =20 > cd / > foo=3Dbin > echo ${foo:a} > echo ${foo:A} > echo ${foo:P} > =20 > for the :a modifier I get > =20 > //bin > =20 > for the :A modifier I get a long pause, followed by > =20 > //bin > =20 > (Is it trying to access a network share?) But for the :P modifier I = get the expected > =20 > /bin Confirmed. The relative path "bin" is converted to the absolute path by chabspath() = in hist.c. It first convert "bin" to "$PWD/bin" =3D "//bin", and then, on systems = other than Cygwin, replace multiple slashes by just a single slash. But on = Cygwin, if the pathname starts with "//" then it is retained, probably to = support the so called UNC: //host/path_to_file. In the following patch chabspath() is modified so that it does not add = an extra '/' if $PWD =3D "/". To be more precise, I have just copied the lines = 932-936 of hist.c (in function histsubchar(), for the :P modifier) to chabspath(). So the = extra '/' is not added if the result of zgetcwd() ends with '/'. # When is it possible that the return value of zgetcwd() ends with '/' = but is not # equal to just "/"? diff --git a/Src/hist.c b/Src/hist.c index 6ac581fda..ea727d1f8 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -1861,7 +1861,11 @@ chabspath(char **junkptr) return 1; =20 if (**junkptr !=3D '/') { - *junkptr =3D zhtricat(metafy(zgetcwd(), -1, META_HEAPDUP), "/", = *junkptr); + char *here =3D zgetcwd(); + if (here[strlen(here)-1] !=3D '/') + *junkptr =3D zhtricat(metafy(here, -1, META_HEAPDUP), "/", = *junkptr); + else + *junkptr =3D dyncat(here, *junkptr); } =20 current =3D *junkptr;