Wandering Thoughts archives

2008-12-06

On line endings and honesty

Dear software, I have a small and simple request, from a working system administrator:

Please stop pretending that \r\n and \n are the same thing.

That is, please stop pretending that MS-DOS line endings and Unix line endings are the same thing, because they are not. Pretending that they are is one of those collective hallucinations that only work if absolutely everyone is playing along. Sooner or later (usually sooner) you will run into a program that does not play along, and things go violently off the rails.

(By 'you' I actually mean 'I'.)

If you are a Unix program and you want to be helpful this way, you should have an explicit switch to turn on ignoring the difference, and this switch should not be on by default. (And if you are a Linux distribution, you should not turn this switch on for me to be helpful. Turning it on is not doing me any favours; rather the contrary.)

In fact, let me be pretty strong: programs that are helpful this way (including both vim and less and, as I found out today, kdiff3) are actually harmful, because their lies make it much harder to diagnose what is going on when some program does notice or object, transforming an ordinary problem into a frustrating, time-consuming mystery. If I have to drag out od to diagnose my problems, you are doing it wrong.

(The most frustrating problems are when programs notice in small ways, such as changing the value of the last field in all of the lines because they now have invisible ^Ms at the end. Programs that object are actually the easy case.)

sysadmin/LineEndingHonesty written at 02:44:00; Add Comment


Page tools: See As Normal.
Search:
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.