PDA

View Full Version : [SOLVED] ^M character in file when checked out into Windows



qmqmqm
July 30th, 2010, 07:11 PM
When checking out files into Windows using a revision control system (e.g. cvs), make changes to the file, then check it back into cvs, every line will have a trailing “^M” generated from Windows.

So when the file is checked out into a unix system afterwards, it will show the “^M” characters at the end of each line.

Is there a way to avoid the “^M” characters after working on the file in Windows; or remove these characters before checking it out into a unix system?

Is there a configuration that can be set in the IDE, or in CVS, that automatically handles this?

Thanks a lot.

worseisworser
July 30th, 2010, 07:24 PM
The editor you use on Windows needs to be configured to use "Unix style newlines".

soltanis
July 31st, 2010, 01:40 AM
If you can't get Windows to cooperate or just need to batch convert the newlines back, you can use the dos2unix (http://gd.tuwien.ac.at/linuxcommand.org/man_pages/dos2unix1.html)(1) program.

lisati
July 31st, 2010, 01:48 AM
Unashamed plug for a similar utility to the better known "dos2unix" and "unix2dos" utilities: http://lisati.homelinux.com/fixlinebreak.html
It's not particularly well written but it does the job and is portable.

dribeas
July 31st, 2010, 06:52 PM
Depending on the revision control system you use, you might be able to configure [pre-]commit hooks to perform operations on the files before they are stored in the revision control system. You can then use dos2unix or similar scripts to remove the '\r' at the end of the lines.