This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] sln: Install as a hard link to ldconfig


On 02 Aug 2016 12:04, Florian Weimer wrote:
> On 07/21/2016 08:22 AM, Mike Frysinger wrote:
> > On 13 Jul 2016 14:17, Florian Weimer wrote:
> >> +/* Check if we have to run sln.  */
> >> +bool
> >> +run_sln (const char *argv0)
> >> +{
> >> +  const char *slash = strrchr (argv0, '/');
> >> +  const char *progname;
> >> +  if (slash == NULL)
> >> +    progname = argv0;
> >> +  else
> >> +    progname = slash + 1;
> >> +  return strcmp (progname, "sln") == 0;
> >> +}
> >
> > GNU programming conventions say to not rely on argv[0] to change
> > behavior:
> 
> > 	https://www.gnu.org/prep/standards/html_node/_002d_002dversion.html
> 
> Can you provide an exact quote?  I don't see it.

i was looking at this part:
  The program’s name should be a constant string; don’t compute it from argv[0].

but Jim's quotes are more relevant in this setup

> coreutils supports this,

i don't think that's all that accurate.  i'm assuming you're referring to
the "coreutils" multicall binary (which i was involved with merging).  it
was merged as a concession to many alternative projects (e.g. busybox),
with specific embedded scenarios in mind, is not the default build mode,
and it includes a configure option to install small scripts rather than
symlinks specifically to deal with the invocation issue (and avoiding the
use of argv[0]).  afaik, coreutils doesn't use argv[0] in other places.

> and bash pretty much requires looking at argv[0].

not really ... while it does have historical support for checking a "-"
prefix and changing its behavior based on that, it is not a requirement.
it works just fine with flags like --login and is the preferred method.

don't get me wrong -- personally, i often use argv[0] in multicall progs
and require proper symlinks to dtrt.  but GNU projects are strongly
discouraged from doing so, and glibc is a GNU project.
-mike

Attachment: signature.asc
Description: Digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]