Wandering Thoughts archives


Why commands can never afford to get it wrong in a version

Netcat is a nice, handy program; there are any number of circumstances in scripts and the like where what it does is just what I want. I don't use it, though. Instead, I have my own simple netcat-like program (called tcp) that I use instead.

There are a number of reasons for this, but one significant reason is that some versions of netcat get the end of file logic wrong. When they see end of file on standard input, they just close standard input; they don't signal the network server that no further input is coming. This behavior can be worked around in some but not all circumstances.

This netcat bug has since been fixed, but a buggy version of netcat made it into some Linux distributions and is still on some of the machines that I use. Since the buggy netcat exists on some machines, I can't trust netcat in general on an arbitrary machine and so I can't use netcat in any script that I want to run unedited on all of our machines; on some machines I will need to use a substitute that doesn't have the bug.

(Like many sysadmins I try to write generic scripts, especially seeing as we have a heavily NFS-based environment.)

And you know, if I've got to use a substitute on some machines it's simpler to use the substitute everywhere. I need to push around the substitute as well as the scripts, but once I've done that I have one less thing to remember, and I have a building block that works consistently everywhere.

This is why commands can't afford to get it wrong, ever. As far as sysadmins with lots of machines are concerned, if it's broken anywhere it's broken everywhere, and accidentally broken commands have a distressing habit of getting packaged and distributed on you. Once a flawed version of your command is out there in the field, well, see the deprecation schedule. I'm sure the netcat people had good intentions, but the end result is that netcat often might as well not exist for me.

(Actually, it's really too late in general once sysadmins start having to use a substitute. I'm extremely unlikely to revise my scripts in three or four years to start using netcat instead of my substitute, given that everything still works fine and it would thus be pointless make-work.)

PS: I'm aware that netcat has many, many more features than acting as a simple network copy command. But I generally don't need those features and I do periodically need a network copy command.

sysadmin/NeverGetCommandsWrong written at 01:07:20; Add Comment

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

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