Making Your Unix Command Names Unique

I’ve been a Unix-head working exclusively in one flavor or another of Unix for more years than I care to contemplate. These days, I seldom see a Unix workflow tip that I didn’t already know about. Still, I do sometimes stumble across something new and useful. The latest such stumbling is this tip from Brandon Rhodes explaining how to make your Unix command names unique.

It’s a common problem. You’ve written a script or compiled program to perform some task only to find that your chosen name conflicts with one of the system command names. Even worse, a system update introduces a command with the same name as one of your longstanding commands.

Rhodes’ solution is incredibly simple but I’ve never seen anyone recommend it before. The idea is simply to preface your command names with a comma. Your reaction is probably like mine, “Wait, that can’t be legal syntax.” But it is and best of all none of the system commands use the convention. That means that starting your command names with a comma guarantees they won’t conflict with any of the system names.

There are other candidates for a unique leading character but as Rhodes says the comma is ideal because it is both unique and easy to type. His solution is much better than prefacing the command with “my-” or your initials. It’s one extra, easy-to-type character that solves the problem once and for all.

This entry was posted in General and tagged . Bookmark the permalink.