coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: That '[' file in /usr/bin


From: Bob Proulx
Subject: Re: That '[' file in /usr/bin
Date: Sun, 3 Mar 2013 15:51:40 -0700
User-agent: Mutt/1.5.21 (2010-09-15)

H. Peter Anvin wrote:
> Mike Frysinger wrote:
> > an example of why argv[0] can be bad: doing execve with argv[0] set
> > to NULL is not an error, and apps that rely on argv[0] will usually
> > segfault immediately. or they won't be able to figure out how
> > they're supposed to behave.
> 
> Invalid example.
> 
> You are talking about a bug; a miscoded application.  Incidentally
> this is an error common to a lot of application regardless of this or not.

Agreed.  A segfault for that reason would be a simple program bug.

> Any application that depends on argv[0] obviously needs to decide on
> its fallback behavior: either error out or apply a default.
> 
> I think the only *valid* reason for not relying on argv[0] is that it
> can result in unexpected behavior for symlinks.

The autotools allow setting a program prefix when building the
program.  When compiling GNU tools on a non-GNU system such as
Solaris, HP-UX, AIX, other then it allows the GNU tools to have a
prefix.  gls, gdd, gln, gcp, and so forth.  Or perhaps they would set
gnuls, gnudd, gnuln.  Or some other moniker.

Programs that looked at their own names would need to take the builder
set prefix into account.  And what if someone renames the program
later?  Build it with one name but then rename it to another later?
It just opens a can of worms.  It is more reliable and consistent to
avoid using the program name to control behavior.

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]