windowsbashmsyslnmklink

Get real windows directory of mounted directory in MSYS (or use ln with MSYS)


I have an MSYS installation, and I am writing a bash script to set up some files. I would like to make a directory symbolic link from the bash script in MSYS, but to do that I will need to use mklink /D, which is a windows command. ln does not work with NTFS symbolic links, it only seems to copy the folder, so I cannot use that unfortunately.

I have a directory mounted as /opt in MSYS using fstab. The real directory is C:\opt (but it could be anything)

mklink expects a Windows-style path like C:\opt. However, I can only provide /opt which it cannot work with. Is there any way to get the "real" path of /opt?

Alternatively, if there's a way to get ln to work like mklink /D that'll be great. But I can't seem to find a way (there does exist a way in Cygwin however but it didn't seem to work for me)

Note: I do not have cygwin, and I do not want to install external software (including cygwin)


Solution

  • I figured it out somehow, although it is kinda an ugly hack

    If I want to figure out the real Windows path of the current directory, I can used pwd -W, which is apparently an MSYS-only feature

    In my script, I can probably do something like:

    realpath=`cd /opt && pwd -W`
    

    to get the real path of /opt. I tested it and it seems to work.

    I'd appreciate a less ugly method though