Re: Discrepancy in regards to program_name output
Bruno Haible <[email protected]> Wed, 09 Jun 2021 21:56:34 +0200
| Newsgroups | gmane.comp.gnu.m4.bugs |
|---|---|
| Message-ID | <5620001.vUDQfWLcbL@omega> |
Sören Tempel wrote: > > tl;dr If argv[0] is a full path (e.g. because of qemu-user usage), > > many tests will fail because --help uses argv[0] while error messages > > use basename(argv[0]). Yes, that's the cause. Good analysis. > > Not sure how to resolve this, if getprogname is expected to return > > basename(argv[0]) the following comment in lib/progname.c is incorrect, > > since getprogname, not lib/program.c is used for error messages: Some error messages use argv[0], some other error messages use basename(argv[0]). GNU programs are not 100% consistent in this aspect. But the usage message definitely uses argv[0] more often, because when a user has provided wrong command-line option, sometimes it's because they invoked the wrong binary. In this situation it's important to distinguish /some/hidden/place/bin/m4 and /usr/bin/m4. Bruno