Subject: Re: usage() function.
To: Matthias Buelow <mkb@altair.mayn.de>
From: Simon Burge <simonb@netbsd.org>
List: tech-userlevel
Date: 10/28/1999 10:50:10
Matthias Buelow wrote:

> [ inflexibility ]

I'm starting to think that it was another idea that should have waited
until after another coffee :-(

> With usage() as above, you'd still have to get the program's name somehow,
> for other messages your program might produce; with my in-line proposal,
> you can store myname for later use.

On NetBSD, __progname is set up as the last component of argv[0] for
you by the program startup mechanism (look in /usr/src/lib/csu).  The
following is an example:

	alpha:/tmp 29> cat > foo.c
	main()
	{
	 extern char *__progname;
	 puts(__progname);
	}
	^D
	alpha:/tmp 30> cc -o foo foo.c
	alpha:/tmp 31> ./foo
	foo

Simon.