Rationale for line-ending recommendation?

Gary R. Van Sickle g.r.vansickle@att.net
Fri Dec 19 09:43:00 GMT 2008

> From: Spiro Trikaliotis
> Hello David,
> * On Thu, Dec 18, 2008 at 05:42:20PM -0900 David Abrahams wrote:
> > 
> > Can anyone explain why the installer began recommending using *nix 
> > line ending conventions?  DOS-compatible endings have 
> always "just worked"
> > for me and I've heard of lots of problems doing it the 
> now-recommended 
> > way.
> Personally, I also install it with CR/LF line endings.

Me too, and like you and the OP report, it "just works" 99.44% of the time.
Of course, since it's not the 21st century yet, many Unixoid programs are
still unable to handle text files properly, hence the remaining 0.66%.

> However, I noticed one problem this way: xfonts. If you 
> install xfonts on cygwin with CR/LF line endings, the fonts 
> end up corrupt, and you cannot start X. I was bitten by this 
> problems many times, whenever I installed a fresh Cygwin.
> To fix this,

You mean "work around this broken software".  Presumably this will be
"fixed" sometime in the 21st century, whenever that starts.

> I use the following way: I mount /var/cache 
> (which also has
> /var/cache/fonts/) in binmode, and reinstall xfonts.
> This is a long-running problem.

Indeed, but hardly surprising, since all indications are that handling text
files is an NP-Hard problem.

> Another problem I once had, but which might have been fixed 
> in the meantime, was the gcc compiler for the Lego 
> mindstorms: It did not accept sources files with DOS line 
> endings. Note, however, that this was 2000 or 2001, so it 
> might have changed in the meantime.

Gcc was broken for a while, but that did in fact get properly fixed quite a
while ago.

> Oh, and Subversion is problematic, too. Because the SVN 
> developers decided to handle line endings on their own using 
> libapr, opening files in binary mode and reading and writing 
> CR, LF or CR/LF on their own,

This is the right way to do things...

> on Cygwin, SVN is hard-coded to 
> *nix line endings. This is not nice. Note that this approach 
> will also fail badly if you mount parts of your system in 
> textmode, and parts in binmode.
> Because of this, I am using an SVN version which I compiled 
> myself with a patched libapr.

...I'm not following this.  Are you talking about the SVN repository, or the
clients, or...?  What's the issue?  I know CVS had some problems with the
dreaded \n/\r\n issue back in the day, but I wasn't aware of similar
Subversion issues.

> Other than that, I never had any problems with the CR/LF line endings.

Bash has some known problems in this area, but there's a Cygwin-specific fix
(that unfortunately is off by default) which hopefully will get accepted
upstream sometime in the next century.

> However, the rationale might be that most problems are 
> testing better with LF line endings, as they come from the 
> *nix world. Remember, on *nix systems, the difference between 
> opening a file in text- or in binmode is practically 
> non-existant. Thus, many programmers do not care about the 
> "right" mode.

Well, better stated, they assume they can treat all files - text,
executables, jpegs, whatever - as if they were Unix-formatted text files.
Of course, they're not, hence problems ensue.

> Best regards,
>    Spiro.

Gary R. Van Sickle

Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

More information about the Cygwin mailing list