From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Bug with :P modifier when current directory is the root
Date: Sat, 11 Mar 2017 12:05:32 -0800 [thread overview]
Message-ID: <170311120532.ZM3348@torch.brasslantern.com> (raw)
In-Reply-To: <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;
next prev parent reply other threads:[~2017-03-11 20:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-11 2:25 Bart Schaefer
2017-03-11 8:47 ` Daniel Shahaf
2017-03-11 20:05 ` Bart Schaefer [this message]
2017-03-12 1:58 ` Oliver Kiddle
2017-03-12 2:59 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=170311120532.ZM3348@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).