Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug with :P modifier when current directory is the root
- X-seq: zsh-workers 40832
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Bug with :P modifier when current directory is the root
- Date: Sat, 11 Mar 2017 12:05:32 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=2JDMM/ZGMJCHv8LxuyKOq0Lq0OKw31MM6nY2+MAoFys=; b=wDbvO9zY5WFt8MKEoNcYB7a+4OZb+Y0puos/6mVUQp+RT9yzWpI4CiymwoHLoomaHp RwdeG5SnFLX1PgOxC/IdRdl9FW7YDyMsUA+Yevdt/GaNg6sQOzMikdNEEpE5AsGjODuy cIhfOMXUloVaqRgVLd5yhoX/o20TwmiYFS/HIJm0G/vvz4/dGkReDMKbnITYT631JJsy TCh9RszNpdfp4ffNRkRw4CTUZRirnBrVEZpMCHuZL8u1oVyzVcMyT2g09gNaymnXCGVr FMNTtNslN6jKC5MMQzwLyJii50H0qqCxXAC3gHGFH0zD82fl8nfZH708xWCsND1njtPK 0H1A==
- In-reply-to: <20170311084745.GA5364@fujitsu.shahaf.local2>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <170310182501.ZM17524@torch.brasslantern.com> <20170311084745.GA5364@fujitsu.shahaf.local2>
On Mar 11, 8:47am, Daniel Shahaf wrote:
}
} zgetcwd() can return "." if the current working directory has been
} deleted by another process.
One of those cases it's annoying to have to waste time on, since it is
so rare and the result will be broken anyway, but I suppose I should
commit it like the below.
diff --git a/Src/subst.c b/Src/subst.c
index 2214b3d..e639c96 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -4336,7 +4336,11 @@ modify(char **str, char **ptr)
break;
case 'P':
if (*copy != '/') {
- copy = zhtricat(metafy(zgetcwd(), -1, META_HEAPDUP), "/", copy);
+ char *here = zgetcwd();
+ if (here[strlen(here)-1] != '/')
+ copy = zhtricat(metafy(here, -1, META_HEAPDUP), "/", copy);
+ else
+ copy = dyncat(here, copy);
}
copy = xsymlink(copy, 1);
break;
@@ -4418,7 +4422,11 @@ modify(char **str, char **ptr)
break;
case 'P':
if (**str != '/') {
- *str = zhtricat(metafy(zgetcwd(), -1, META_HEAPDUP), "/", *str);
+ char *here = zgetcwd();
+ if (here[strlen(here)-1] != '/')
+ *str = zhtricat(metafy(here, -1, META_HEAPDUP), "/", *str);
+ else
+ *str = dyncat(here, *str);
}
*str = xsymlink(*str, 1);
break;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author