Subject: Re: programs using getprogname()
To: None <>
From: Chris G. Demetriou <>
List: tech-userlevel
Date: 03/22/2001 08:22:05
In response to changing mkdep to use getprogname(), I received the
following message privately.  Since I think it needs to be responded
to more widely, I've stripped off the identifying information and am
responding here.

Somebody wrote:
> It's probably not quite useful to use getprogname(), unless
> the source is shared among several programs.

As far as i'm concerned, this is incorrect.

Say i install 'mkdep' as 'nbmkdep', or 'foo'.

The user invokes those commands, not "mkdep."  They should get error
messages about the command that they've invoked, not about some
'mkdep' command that they didn't invoke.

This is a real issue.  E.g. building cross-compilation tools for other
hosts: if you want to be able to make dependencies, you've gotta have
a NetBSD mkdep.  What do you install that as?

'mkdep' isn't a great name.  Who knows if the host already has a mkdep
program, and, if it does, who knows if it's compatible?  Odds are
against.  'mkdep' isn't that big of an issue.  consider, for instance,
'make'.  Or 'rpcgen' or 'install' or 'yacc' or 'config'.  In the case
of a few in the latter set, we hacks in the programs that e.g. allow
them to generate output more easily compile with a bunch of strict
warning flags.  Can't just use the host versions, and who knows if the
output of the netbsd version would be compatible with the host ... so
better to use a different name.

i use nbmkdep as the name for mkdep, because it's "NetBSD mkdep".
(just like i have nbmake, nbmtree, nbconfig, etc.)

(For some of these, also, it may be of further use to hard-code the
compiler default to something else, e.g. foo-netbsd-gcc, in which case
nbmkdep should probably also become: foo-netbsd-nbmkdep.)

And, of course, when an error occurs in these programs, the user
should be presented with consistent error codes that name the correct

So, really, the actual correct style is almost diametrically opposed
to the one presented in the e-mail message to me, as far as i'm

_No_ program should hard-code its program name, unless it's got a
_very_ good reason to.

(I happen also to be with the GNU folks on the issue of multiple links
to a single program having different behaviour, based on name.  you
should be able to rename binaries arbitrarily, or e.g. invoke them
through arbitrarily-named symlinks, and not be surprised by the

Chris Demetriou - -
Disclaimer: Not speaking for NetBSD, just expressing my own opinion.