Skip to content

Posix shells on Windows might not have, nor require, cygpath #1148

@cspotcode

Description

@cspotcode

busybox.exe sh is the ash shell on Windows. It uses native windows paths -- G:\foo\bar or G:/foo/bar -- so it doesn't need nor provide cygpath.

Is it reasonable for zoxide init to only call cygpath conditionally, if it's found, skipping it otherwise?

# In busybox.exe sh, we already get native windows paths, albeit with forward slashes
$ pwd -P
G:/repro
$ cd 'G:\repro' # <-- It understands backslashes, too

I think this implementation avoids any performance hit by checking for cygpath only once on startup, baking the decision into the __zoxide_pwd implementation:

if \command -v cygpath >/dev/null
then
  __zoxide_pwd() {
    \command cygpath -w "$(\command pwd -P)"
  }
else
  __zoxide_pwd() {
    \command pwd -P
  }
fi

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