From: "Daniel Shahaf" <d.s@daniel.shahaf.name>
To: zsh-users@zsh.org
Subject: Re: P modify in history event
Date: Tue, 19 Nov 2019 19:03:10 +0000 [thread overview]
Message-ID: <f11ea64b-8415-4bbc-bd8c-f4d6342ce763@www.fastmail.com> (raw)
In-Reply-To: <1574187661.6021.15.camel@samsung.com>
Peter Stephenson wrote on Tue, 19 Nov 2019 18:21 +00:00:
> On Tue, 2019-11-19 at 18:00 +0000, Daniel Shahaf wrote:
> > Can «zgetcwd()» return an empty string? If that's possible, the
> > condition will be undefined behaviour («""[-1]»).
>
> Not in a sane world, but there are cases where we can't work out the
> current directory. I think we return "." then, in fact. But a bit of
> safety probably wouldn't hurt --- applying [-1] to functions arguably
> isn't top class style.
How about this, then?
diff --git a/Src/compat.c b/Src/compat.c
index 7131d91a4..02b66a780 100644
--- a/Src/compat.c
+++ b/Src/compat.c
@@ -519,7 +519,7 @@ zgetcwd(void)
#endif /* HAVE_GETCWD */
if (!ret)
ret = unmeta(pwd);
- if (!ret)
+ if (!ret || *ret == '\0')
ret = dupstring(".");
return ret;
}
Cheers,
Daniel
(let's continue the discussion on -workers@)
prev parent reply other threads:[~2019-11-19 19:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20191117184333epcas5p15bc1aa7b0f78182c3d1acc703f55d445@epcas5p1.samsung.com>
2019-11-17 18:42 ` Perry Smith
2019-11-18 9:47 ` Peter Stephenson
2019-11-19 18:00 ` Daniel Shahaf
2019-11-19 18:21 ` Peter Stephenson
2019-11-19 19:03 ` Daniel Shahaf [this message]
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=f11ea64b-8415-4bbc-bd8c-f4d6342ce763@www.fastmail.com \
--to=d.s@daniel.shahaf.name \
--cc=zsh-users@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).