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

Re: :a modifier resolves symlinks - docs say it shouldn't



On Fri, May 29, 2026 at 8:07 PM Langbart <Langbart@xxxxxxxxxxxxxx> wrote:
>
>        a      Turn a file name into an absolute path:  prepends the current
>               directory, if necessary

This does not say that symbolic links are preserved for "prepend the
current directory."

  dir=${PWD}/x
  echo ":a      ${dir:a}"
  echo ":A      ${dir:A}"
  echo ":P      ${dir:P}"

:a      /var/folders/6b/3xjb91g50kq0hpwdyqlry57w0000gp/T/tmp.ACSrdBvO3s/link/x
:A      /private/var/folders/6b/3xjb91g50kq0hpwdyqlry57w0000gp/T/tmp.ACSrdBvO3s/real/x
:P      /private/var/folders/6b/3xjb91g50kq0hpwdyqlry57w0000gp/T/tmp.ACSrdBvO3s/real/x

That is, symbolic links encountered when interpreting the value of
${dir} are preserved (or more accurately, ignored), not when
constructing an absolute path from a relative one afterward.

You can see this more plainly if you change these two lines of your test:

  cd ${tmp_dir}     # don't desend into link
  dir=link/x




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