[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: progname.h contradicts gnu coding standards
From: |
Eric Blake |
Subject: |
Re: progname.h contradicts gnu coding standards |
Date: |
Mon, 19 Mar 2007 22:06:02 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.10) Gecko/20070221 Thunderbird/1.5.0.10 Mnenhy/0.7.4.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to John Darrington on 3/19/2007 9:58 PM:
> The instructions in progname.h say:
>
> /* Programs using this file should do the following in main():
> set_program_name (argv[0]);
> */
>
> /* Set program_name, based on argv[0]. */
> extern void set_program_name (const char *argv0);
Not a bug. set_program_name affects error(), in order to print error
messages based on what the user passed in as argv[0], and NOT to print the
program's official name. And in this instance, you really DO want
argv[0], as the user knows what command they invoked, and not necessarily
the canonical name of that command.
>
>
> but the GNU coding standards say:
>
> "The program's name should be a constant string; don't compute it from
> argv[0]. The idea is to state the standard or canonical name for the
> program, not its file name."
That is in relation to what --version output, or anything else that
outputs the canonical name of a program, should use.
As an example:
$ cp /bin/cp mycp
$ ./mycp
./mycp: missing file operand
Try `./mycp --help' for more information.
$ ./mycp --version | head -n1
cp (GNU coreutils) 6.7
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFF/12p84KuGfSFAYARAlpJAJ4sKxskMJVhGbdRKh8dY9nhzCkQ5wCgm6sE
5ZUx4ZWLqrogVEqXE+PkYso=
=5Ime
-----END PGP SIGNATURE-----