Subject: Re: sysv ps(1) implementation [was: ps(1) sysv silliness]
To: John Hawkinson <jhawk@MIT.EDU>
From: Andrew Brown <>
List: tech-userlevel
Date: 06/08/2000 15:19:42
>>>Checking __progname is extremely poor style.
>>huh?  loads of programs do it all the time...well...argv[0] at least,
>>but that's where __progname comes from anyway.  loads...perhaps
>>they're all just special cases?
>I think they are all special cases, yes.

i think it's just another case of unix giving you enough rope to shoot
yourself in the foot.

>I think most of the above are in fact Bad Ideas(tm), but
>ramdiskbin is a special case.

it's mostly a case of programs that have very similar functionality
changing behavior based on argv[0] instead of having separate
binaries.  it saves on disk space.

>>>Users should be able to copy binaries around
>>>and rename them as they see fit without seeing
>>>strange lossage or behavior changes.
>>    % touch me
>>    % ls -l me
>>    -rw-r--r--  1 andrew  staff  0 Jun  8 12:36 me
>>    % cp /usr/sbin/chown ./foo
>>    % cp /usr/sbin/chown ./bar
>>    % ./foo 0 me
>>    foo: me: Operation not permitted
>>    % ./bar 0 me
>>    % ls -al me
>>    -rw-r--r--  1 andrew  wheel  0 Jun  8 12:36 me
>That's truly special. pr it?

no pr needed.  it's documented in the code, if you read the code and
not any comments.  that particular binary looks at the third character
of argv[0] and behaves as chown if it's the letter 'o', but otherwise
behaves as chgrp.  foo and bar are just convenient ways of
demonstrating that your expectation is not exactly fulfilled.

	myname = (cp = strrchr(*argv, '/')) ? cp + 1 : *argv;
	ischown = (myname[2] == 'o');

>>>While it's acceptable to grandfather in this sort of thing
>>>because it has been there forever, adding new instances of it
>>>should be forbidden.
>>while it's acceptable to do cool things, you should cease from doing
>>new cool things.
>I don't think that parsing __progname is a "cool thing,"
>it's a "hokey broken thing that causes problem." Any new cool
>things can be acheived by either using command line switches or
>installing seperate binaries.

imho, having to specify "grep -G", "grep -E", or "grep -F" is a pain.
grep means grep, egrep means egrep, and fgrep means fgrep, without me
having to tell it so.

on the other hand, i also don't think that having multiple programs
that do somewhat the same thing is a good idea.  i've got too many
versions of sh, ls, ln, and ld on solaris to make me happy, and they
all behave differently.

|-----< "CODE WARRIOR" >-----|             * "ah!  i see you have the internet (Andrew Brown)                that goes *ping*!"       * "information is power -- share the wealth."