Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: P modify in history event
- X-seq: zsh-users 24451
- From: "Daniel Shahaf" <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: P modify in history event
- Date: Tue, 19 Nov 2019 19:03:10 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=mime-version:message-id:in-reply-to :references:date:from:to:subject:content-type :content-transfer-encoding; s=fm1; bh=dhRCv8Xf9MZhgcugHT9wml36o6 3GYXcGjtVb39ytHis=; b=qyNidKWCE5dOxSk8Im/TBeXePQgswUHsBqviHINfSk yf/BT1P1q4gNFy+SRiPnPS5z/dkR0Op2+GdSLosyns+QXf3k2N8reIaGvnFz22AC S8KekGFxgdOESiBdIsycUktoSzcijSxi4RgzkuGypigjUgtHkoAHtSQJ6fd/IHVP KMAdlbKY1EP/Fmi7EQe1gcnDteY0wcA+POe4ofN7zcLAJ6ERWshWkgXX8I3fWrlT GunZ2HU9iiCmjtwNM407Xdq1FBL//ntuE+GkWEXcaZdS0nF2895ERbZHqmGeBzOx tGS6KVTWoLZzIo53jOh/Cfi707yereTDTl0yTm0wc/Jg==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=dhRCv8Xf9MZhgcugHT9wml36o63GYXcGjtVb39ytH is=; b=G4HlgtbxAPrgloKAwUKv53Naoc89qECu2K+18Y7sMpZgoJ7MINxOQ7FZX t4xhLXA0c0edH7ejRzNgzzb18Srq01Gnn46arhGpXDsKCQaiNUwzINWpPBG/bv2a 0FHqmJtL+0fDV9MDQW7qwIrTYYkpK/Df1JFwojGOMMPNdEELFbu0sIWNP5zQt/O1 YphvNPlWfktegOjLdeHtkkKXdcnO0jYRP3garR2U9iF0he+6CkaJ/MA8YP4uH5hA nNGZup47AALlciJDvvj1YrQi81jz/fv1F/f5EjtI0d005JEtRVAPcBTcDCNKsgIb bMWeTeM4esT6bVp6kJoI0L6stzU4g==
- In-reply-to: <1574187661.6021.15.camel@samsung.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CGME20191117184333epcas5p15bc1aa7b0f78182c3d1acc703f55d445@epcas5p1.samsung.com> <BEBF5AEC-185E-4887-98D7-4731E1D8F7B0@easesoftware.com> <1574070429.4551.2.camel@samsung.com> <d64df0bd-0ebb-4f5b-af63-cab62dfbd5fb@www.fastmail.com> <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@)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author