Wednesday, January 18, 2012

"system/command" versus "system command"

A lot of tools have a master command with subcommands. For example
hg clone ...
hg merge

cvs co
cvs update

git clomne
...
I think that the first place I encountered this was with mh. Or, since my friend MH says that mh did not have subcommands, I may have made the following change myself for mh. Why subcommands? I think mainly to avoid name collisions in the bin. Years ago, I kluged - I think it may have been the shell, whoever processes PATH - to search not just for "executable" on the PATH, but also "dir/executable". I.e. instead of saying
hg update
I colud have said
hg/update
Not much of a difference. But it makes it easier for guys to code systems that have lots of subcommands. Also, for users of shells like bash and csh: !hg/update works, whereas "!hg update" doesn't (unless your shell has tweaks.

No comments:

Post a Comment