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

Mike Frysinger vapier@gentoo.org
Tue Aug 2 16:27:00 GMT 2016


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20160802/d51e46f7/attachment.sig>


More information about the Libc-alpha mailing list