Skip to content

Windows can have symlinks, should still respect _ZO_RESOLVE_SYMLINKS #1147

@cspotcode

Description

@cspotcode

The logic here ignores the value of _ZO_RESOLVE_SYMLINKS on Windows, but Windows can have symlinks.

# pwd based on the value of _ZO_RESOLVE_SYMLINKS.
__zoxide_pwd() {
{%- if cfg!(windows) %}
\command cygpath -w "$(\builtin pwd -P)"
{%- else if resolve_symlinks %}
\command pwd -P
{%- else %}
\command pwd -L
{%- endif %}
}

Here is a reproducible example from my busybox.exe (ash) shell:

# Create directory and symlink to it
$ cd G:\repro
$ mkdir directory
$ ln -s directory symlink

$ cd symlink
$ pwd -L
G:/repro/symlink
$ pwd -P
G:/repro/directory

# cygpath is not available on $PATH and is not necessary in busybox.
# But for completeness, just showing that it understands the symlink, too.
$ 'C:\program files\git\usr\bin\cygpath.exe' -w $(pwd -L)
G:\repro\symlink
$ 'C:\program files\git\usr\bin\cygpath.exe' -w $(pwd -P)
G:\repro\directory

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions