Search code examples
bashcygwin

Mounting of /cygdrive/c resolves to C:\cygdrive\c


I am using Cygwin and try to run a bash script which uses the pwd command to construct a path and then generate a directory. The problem is that the directory is created under c:\cygdrive\c rather than under c:\ (when I execute cd /cygdrive/c I will arrive at c:\cygdrive\c. Here are my current mounts:

C:/cygwin/bin on /usr/bin type ntfs (binary,auto)
C:/cygwin/lib on /usr/lib type ntfs (binary,auto)
C:/cygwin on / type ntfs (binary,auto)
C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
E: on /cygdrive/e type vfat (binary,posix=0,user,noumount,auto)

Does anybody know what is configured wrongly?

UPDATE

Let me try to make it more clear (because all comments mention the script but I am sure the problem is not the script): I do the following on the Windows command prompt:

C:\>pwd
/cygdrive/c

C:\>cd /cygdrive/c

C:\cygdrive\c>

But actually the cd should arrive at c:\.

Is it perhaps a problem of the mount order?


Solution

  • OK, finally I have changed my bash script. It first gets the directory in cygwin notation using pwd then transforms all / into \ and finally does the following substitution: s/\cygwin\(.)/\1:\/.

    Why a cd /cygwin/c/someDir when executed from a bash script goes into c:\cygwin\c\someDir rather then c:\someDir I am still not sure (I understand this behavior when I am doing this in a Windows command prompt, but not within a bash script).