filepath icon indicating copy to clipboard operation
filepath copied to clipboard

normalise should eliminate parent directories on Windows

Open Rufflewind opened this issue 8 years ago • 5 comments

Windows seems to interpret paths differently than on POSIX systems.

  • On POSIX, /sym/link/../foo refers to /target/dir/../foo ≡ /target/foo (.. expands after dereferencing).
  • On Windows, C:\sym\link\..\foo always refers to C:\sym\foo (.. expands before dereferencing).

This feature would be useful to have because if you want to pass in extended-length paths (the \\?\ prefix) you have to normalize the path before adding the prefix, otherwise the Windows API will interpret .. literally.

Rufflewind avatar Mar 04 '17 22:03 Rufflewind

What if you do the Windows style path on a Mingw shell - does it expand before or after dereferencing?

ndmitchell avatar Mar 06 '17 21:03 ndmitchell

Tried it in the MSYS shell (that one that comes with Stack):

  • C:\sym\link\..\foo expands before deref.
  • C:/sym/link/../foo expands before deref.
  • /c/sym/link/../foo expands after deref.

Rufflewind avatar Mar 07 '17 02:03 Rufflewind

That's disturbingly inconsistent... I guess you need two separate methods, one which expands .. and one which doesn't.

ndmitchell avatar Mar 07 '17 06:03 ndmitchell

@Rufflewind is this observed behavior or is there something in windows documentation suggesting this is behavior that can be relied upon?

hasufell avatar Nov 25 '21 23:11 hasufell

I have not seen documentation around it but I haven't really tried looking per se. It's just a quirk I observed when trying to test native symbolic links on Windows.

Rufflewind avatar Dec 03 '21 22:12 Rufflewind