> Do you get the same results with :P ? :a and :A are not guaranteed to
> result in a path leading to the same file (eg, symlink/../ will be
> simply deleted without following the symlink etc)
Yes, running with strace confirms that :a,A,P
all exhibit the same lstatting behaviour (they all call zgetcwd).
From:
Mikael Magnusson <mikachu@gmail.com>
Date: Friday, May 20, 2022 at 11:35 AM
To: Stefan Radziuk <sradziuk@pdtpartners.com>
Cc: zsh-workers@zsh.org <zsh-workers@zsh.org>
Subject: (EXT) Re: Using the history expansion modifier 'a' results in excessive lstat calls
On 5/20/22, Stefan Radziuk <sradziuk@pdtpartners.com> wrote:
> zsh uses zgetdir to evaluate ${FOO:a}. When in a directory in a different
> filesystem to its parent, zgetdir will lstat many entries in the parent.
> This leads to slowness, especially when some of the lstatted entries are on
> remote filesystems.
>
>
>
> This behaviour can be avoided by making zsh use getcwd instead (build zsh
> with USE_GETCWD). Interestingly, getcwd will also be used in the regular zsh
> build if zgetdir fails (see the implementation of zgetcwd).
>
>
>
> I have looked through some threads in the mailing list to find out why
> zgetdir is being used over getcwd in the first place. It seems it was
> implemented this way in the 1990s to work around a bug in some
> implementations of getcwd, which should not be a concern on modern systems.
>
>
>
> I was wondering if zgetdir is still the right way to do this? Are there use
> cases where it is preferred over getcwd? Maybe zgetcwd could simply use
> getcwd primarily (i.e. not as fallback), or perhaps USE_GETCWD could be
> enabled by default (currently it is only enabled on QNX builds).
Do you get the same results with :P ? :a and :A are not guaranteed to
result in a path leading to the same file (eg, symlink/../ will be
simply deleted without following the symlink etc)
--
Mikael Magnusson