|
Cygwin CR/NL problems Christopher Brooks, 26 Aug 2002 Last updated: 10 Oct 2005
When Cygwin is installed, you should be sure to select
DOS for the Default Text File Type.
If you do not, then when you check in files, there
will be problems with the DOS CR/NL line endings.
In particular, what will happen is that when you
check in a file and then someone checks it out, it
will have extra \r or ^M characters.
The way to tell if this is a problem is to run
the mount command under Cygwin bash and
note whether the c: drive is mounted
textmode or not. If the c:
drive is mounted textmode, then
your setup is ok:
$ mount
c:\cygwin\bin on /usr/bin type system (textmode)
c:\cygwin\lib on /usr/lib type system (textmode)
c:\cygwin on / type system (textmode)
c: on /cygdrive/c type user (textmode,noumount)
However, if c: is mounted binmode,
then you have problems:
$ mount
c:\cygwin2\bin on /usr/bin type system (binmode)
c:\cygwin2\lib on /usr/lib type system (binmode)
c:\cygwin2 on / type system (binmode)
c: on /cygdrive/c type user (binmode,noumount)
The fastest solution is to reinstall Cygwin,
see How do I edit pages in a group with the "CVS Authoring" option?
and properly select
DOS for the Default Text File Type.
Another possible alternative is to use these mount
commands:
We have tried these commands but they have not
quite worked for us
mount -f -t -s c:\\cygwin\\lib /usr/lib
mount -f -t -s c:\\cygwin\\bin /usr/bin
mount -f -t -s c:\\cygwin /
mount -f -t c: /cygdrive/c
If you have a d: drive,you may need to do:
mount -f -t d: /cygdrive/c
When you are done, run mount, which should
show all the mounts as textmode.
The reason that this is a problem with CVS is that
CVS handles end of line translation between Unix and Windows.
If, under Cygwin, the directories are mounted
binmode, then Cygwin CVS will not do
the proper translations.
For details, see
How is the DOS/Unix CR/LF thing handled? in the Cygwin FAQ
See also
http://cygwin.com/cygwin-ug-net/using-textbinary.html
To replicate the problem, install Cygwin with Unix line
endings, check out a file using CVS, edit the file using
wordpad and check in your changes. When you check out
the file under Unix, it will have \r\n
line endings.
Note that there is some contention about whether
DOS or Unix line endings are correct. The TinyOS community
has required Cygwin to be set up with Unix line endings,
which works great if your users are technically
sophisticated. However, if your windows users do not have
much exposure to Unix, then configuring Cygwin to use
DOS line endings is more correct. |