[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] progname: also set global program_invocation_name, when poss
From: |
Jim Meyering |
Subject: |
Re: [PATCH] progname: also set global program_invocation_name, when possible |
Date: |
Tue, 25 Aug 2009 09:58:11 +0200 |
Sergey Poznyakoff wrote:
>> +#if HAVE_DECL_PROGRAM_INVOCATION_NAME
>> + program_invocation_name = (char *) argv0;
>> +#endif
>
> In my opinion, that's not correct. Libc (and gnulib's argp, FWIW) uses
> two variables: program_invocation_name, which points to the full program
> name as obtained from argv[0], and program_invocation_short_name, which
> points to the program name with all leading directories removed. So,
> set_program_name should set program_invocation_name to arg0, and
> program_invocation_short_name to part of arg0 after the last directory
> separator.
Hi Sergey,
I understand your point.
However, keep in mind that the goal of set_program_name is to sanitize
a libtool-munged argv[0], so that diagnostics don't include ".libs/lt-"
in the program name part.
I have no control over glibc's error, and it uses program_invocation_name,
not program_invocation_short_name, so in order to make diagnostics appear like
program_name: ....
rather than
/abs/dir.../.libs/lt-program_name: ....
the set_program_name function must update program_invocation_name.
Unfortunately, when using libtool, and looking solely at argv, we cannot
derive the true command invocation name, so we cannot determine whether
the tool was invoked via ../../usr/bin/program, /usr/bin/program, or
simply "program".