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

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



On Fri, Oct 20, 2023 at 8:18 PM Kyle Laker <kyle@laker.email> wrote:
>
> I have found a strange behavior with ZSH when working with
> systemd-homed. After running `pwd -P` within my home directory, it seems
> as if the current working directory effectively changes to `/`. I am
> currently using ZSH 5.9 and systemd 254.
>
> systemd-homed is configured using a BTRFS subvolume.

This sounds like it must be the same issue as workers/52213 which also
involves doing operations on BTRFS mounts.

> What is unexpected is that after running
> `pwd -P` all other subprocesses act as if the `cwd` is `/`

When you run `pwd -P`, zsh invokes the getcwd() system call and prints
whatever it returns.  That's literally all it does.  So, although I
don't have BTRFS to test with, this looks from here like a problem
with getcwd() internally changing the process current directory to the
root when crossing a BTRFS link.  That would be invisible to $PWD and
therefore to the pwd command (without -P).

There are some cases where zsh itself would change the current
directory, e.g., if the parent of the current directory is removed
from the filesystem and a few other "catastrophic failure" cases, but
zsh would display a warning message in those circumstances and in your
example its happening silently ... another clue that whatever it is,
is behind zsh's back, so to speak.




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