[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Discrepancy in regards to program_name output
From: |
Bruno Haible |
Subject: |
Re: Discrepancy in regards to program_name output |
Date: |
Wed, 09 Jun 2021 21:56:34 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; ) |
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