Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Re: `pwd -P` with systemd-homed causes inconsistent cwd state



On Sun, Nov 5, 2023 at 6:17 AM Kyle Laker <kyle@laker.email> wrote:
>
> I've attached a patch that builds on yours.

Thanks.  I believe there's still some more that could be done here --
for example

+    if (!getcwd(buf, bufsiz)) {
+        if (d) {
+            return NULL;
+        }
+    } else {

The "if (d)" is extraneous here, we're just going to return NULL later
anyway.  That test implies that we'd later be attempting to use
fchdir() [via zchdir?] but in the failure case we won't.  I know you
carried this over from the previous code but it's extraneous there too
so we might as well fix it.

> The patch also removes
> `GETCWD_CALLS_MALLOC` because it was only used in that fallback case.

I think the reason for that may have been that a reason for failure is
that the buffer isn't large enough.  Rather than remove this, I think
it should actually be moved into zgetdir().

I'll put something together a bit later today, but in the meantime
would be interested in feedback from anyone else who has a better idea
how we arrived at this state (and possible what really is going on in
lchdir() ...).




Messages sorted by: Reverse Date, Date, Thread, Author