I've run headlong into a weird bug. I have a MacBook Pro running Mac OS X. I'm running Parallels on it with Windows XP as the guest OS. I have my OSX home directory mounted in XP as a shared drive (Z
. Pretty typical.
I have Cygwin installed on XP. If I run the following commands in Cygwin:
echo foo >> /cygdrive/z/test
echo bar >> cygdrive/z/test
cat /cygdrive/z/test
I get:
^@^@^@^@bar
Basically, running the second command (which opened the Z:\test file in append mode) replaced the file's contents with an equal number of NUL (ASCII 0) characters before appending the new data.
If I run this test on the Windows XP drive, there's no problem:
echo foo >> /cygdrive/c/test
echo bar >> /cygdrive/c/test
cat /cygdrive/c/test
foo
bar
And, the thing that floors me is that if I try this from DOS, it works:
echo foo >> Z:\test2
echo bar >> Z:\test2
type Z:\test2
foo
bar
Can anyone reproduce this, and has anyone seen this before? I'm not sure what's going on, since at least two factors (Cygwin Bash shell and Parallels shared folders) must be present for the problem to occur. Right now, I can't figure out which factor is the real cause, and I don't know enough Windows internals to go deep-diving into the OS layers. I have tried both Bash versions that Cygwin offers (3.0.x and 3.1.x) and both show the same problem, so it might be cygwin1.dll and not bash.
The reason I ran into this is that I was trying to cross-compile some code in my OSX home directory under Windows, and the program that generates my makefiles (which uses bash and perl to do its work) gave me a NUL-filled makefile. The workaround is to copy my files to the Windows XP volume, but that's kludgy and the XP volume doesn't have a huge amount of free space.