Date: Sat, 27 Jun 2009 04:16:03 +1000 (EST) From: Bruce Evans <brde@optusnet.com.au> To: d@delphij.net Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Xin LI <delphij@FreeBSD.org>, Bruce Evans <brde@optusnet.com.au> Subject: Re: svn commit: r194789 - head/usr.bin/usbhidctl Message-ID: <20090627033608.P35379@delplex.bde.org> In-Reply-To: <4A43B727.7010204@delphij.net> References: <200906232316.n5NNG1iT094289@svn.freebsd.org> <20090625154007.H33864@delplex.bde.org> <4A43B727.7010204@delphij.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 25 Jun 2009, Xin LI wrote: > Bruce Evans wrote: >> On Tue, 23 Jun 2009, Xin LI wrote: >> >>> Log: >>> Use getprogname() instead of referencing __progname. >> >> Neither is permitted in FreeBSD in usage(). > > I didn't see references about this? If this is discouraged, perhaps we > should mention it in style(9) or somewhere. FreeBSD style(9) simply doesn't mention getprogname(), while NetBSD share/misc/style requires it in the example usage(). Actually, it is OK to use it in FreeBSD iff the system supports the same program having different names, like reboot/halt/etc. > It looks like that a lot of > programs are using (not necessarily from NetBSD), but also others. Do > we have some discussion in the past regarding this? Most are still from NetBSD, except for lots in tools/regression. Most other uses are still correct ones, for things like setproctitle() (and for not so correct things like fprintf() -- why not use warnx()?). This was discussed in FreeBSD mailing lists years ago, and IIRC no one disagreed with the existing practice of hard-coding the program name. It can be considered a feature that if you copy or rename "cp" to "foo", its usage message reminds you that it is still "cp". >>> Modified: >>> head/usr.bin/usbhidctl/usbhid.c >> >> This was obtained from NetBSD, which requires using getprogname() in >> usage(). > > This is purely coincidence... I didn't even looked at NetBSD code in > this case, otherwise I would have brought the TNF copyright changes, > etc. altogether. The __progname in usbhidctl was obtained from NetBSD. Without this, the usage() function would have been a normal one and you shouldn't have needed to fix it. NetBSD of course fixed it long ago (FreeBSD obtained the bug in 2000 and it was fixed in NetBSD in 2001). In my 2005 copy of NetBSD, all usage() messages in utilities seem to have been roto-tilled to use getprogname(). This gives 343 files matching getprogname in NetBSD 2005 (incomplete sources but I forget how incomplete). FreeBSD now has only 88 files matching. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090627033608.P35379>