Cygwin 3.3.4 - cmd to symlinked path doesn't work
Thu Feb 3 11:34:13 GMT 2022
On Feb 3 13:56, Andrey Repin wrote:
> Greetings, Corinna Vinschen!
> > On Feb 1 15:47, Andrey Repin wrote:
> >> The interesting part is that the behavior is dependent on sequence of events.
> >> `mintty bash -i` in a directory:
> >> > $ pwd
> >> > /cygdrive/d/cygwin
> >> > $ cmd
> >> > Microsoft Windows [Version 6.1.7601]
> >> > Copyright (c) 2009 Microsoft Corporation. All rights reserved.
> >> >
> >> > D:\cygwin> exit
> > Not sure how you did that,
> Did what? Opened an interactive shell in a directory? Navigated into it in a
> different file manager and just used a command.
That's the trick! I never use this functionality so I wasn't able to
> Opened CMD in an UNC path?
> reg ADD "HKCU\\Software\\Microsoft\\Command Processor" /f /v "DisableUNCCheck" /t REG_DWORD /d 1
> Not even required to re-login.
> Or globally for entire system in HKLM\SOFTWARE\Microsoft\Command Processor
Ahhh, thanks for this registry key setting. I remembered vaguely that
such a setting exists, but my internet searches failed to uncover it, so
I thought I had imagined things :)
> > Reparse points created with mklink /d are evaluated as symlinks. This
> > reparse point contains an absolute UNC path. If you cd to this dir in
> > Cygwin, Cygwin evaluates the path and reads the symlink content. Given
> > the content is an absolute path, the symlink content replaces the
> > entire path. Internally the CWD is stored twice, once in POSIX, once
> > in Windows syntax. In short, what happens is this:
> > pwd -> POSIX(/cygdrive/d), WIN(D:)
> > cd cygwin ->
> > open reparse point "cygwin"
> > read content == "\\server2\share\folder1"
> > convert to POSIX == "//server2/share/folder1"
> > restart path evaluation and check for further symlinks
> > -> no further symlinks
> > convert path to Windows == "\\server2\share\folder1"
> > store both paths as new CWD
> > pwd -> POSIX(//server2/share/folder1),
> > WIN(\\server2\share\folder1)
> > So what happens in bash?
> > $ pwd
> > /cygdrive/d
> > $ cd cygwin
> > $ pwd
> > /cygdrive/d/cygwin
> > $ /bin/pwd
> > //server2/share/folder1
> Except if you don't "cd", it uses whatever is given by the operating system.
Yeah, that's right and explains that this worked for you. We could run
GetFinalPathNameByHandleW on the CWD if the Cygwin process is the root
of the process tree, but I'm not sure it's worth it.
> I though, by the time everybody had learned to suppress that stupid CMD
> behavior, but here it is once again.
Yeah, guilty as charged. Thanks again for the registry key!
More information about the Cygwin