What do you recommend as a default fallback for line endings if the operating system cannot be determined?
Example
Mac OS up to version 9 uses carriage returns (r
) for line endings. Unix-like systems do line endings with line feeds (n
) and Windows uses two characters (rn
) to mark a line ending.
What’s the best fallback which is most compatible for all mentioned systems when writing code files which are exchanged with developers on different platforms?
5
I would vote for CRLF:
- Windows is still the most widely used OS for personal computing, therefore all other OSs have ways to deal with DOS line endings
- The opposite is not necessarily true, not all Windows apps can deal with Unix or Mac line endings
- CRLF is also the line ending for all Internet Standards and RFCs, e.g. HTTP, MIME, Usenet, Internet Mail, vCard, iCal etc.
3
For interpreted languages: use one that is supported by an “execution platform” (e.g. an application server) OS. That’s because you should probably use the same OS for development in a first place. Also you may find yourself in a situation when you need to read or change (not a good idea, but possibility) deployed sources.
For compiled languages: I see no reasons why any choice should be favored, except there is some explicit requirement or if the majority of developers use any particular OS.
My 2¢:
- Pick any EOL encoding you want, but make sure it plays well with your build system, compilers, interpreters, etc.
- Make sure that this is cleanly explained in your wiki page, readme files, etc, intended for contributors.
- On the same page explain how to
git config core.eol
properly, so that contributors have an easy time sending pull requests.
Hopefully after that you’ll be able to stop caring about EOLs in source files.