[net.unix-wizards] "Re: Undocumented Stuff"

hom@hocda.UUCP (H.MORRIS) (03/22/84)

Speaking of undocumented things, the most startling one I know
of is the third argument to main() which exists on every U**X
I have worked with, and which points to the list of environment
variables.  Normally you don't declare it and that is fine,
but I started noticing some utility programs with this argument
(like many version of shell would have to have it).
If it's documented anywhere, I'd be interested in knowing
about it.  E.g. to print the list of environment variables:
main(argc, argv, envp)
char	*argv[], *envp[];
{
	register char	**p;

	for(p=envp; *p ; ++p)
		puts(*p);
}
Does anyone have a UNIX on which this doesn't work?

gwyn@brl-vgr.ARPA (Doug Gwyn ) (03/25/84)

main( argc, argv, envp ) most certainly is documented, in exec(2)
(even in 4.2BSD, will wonders never cease).  6th Edition and older
UNIXes did not support this because they did not have environments.

nather@utastro.UUCP (Ed Nather) (03/30/84)

<>
Steve Bourne's book "The Unix System" describes in detail the third
"environmental" argument to main(), and also says it sees little use.
He seems faintly unhappy about it.

-- 

                                       Ed Nather
                                       ihnp4!{ut-sally,kpno}!utastro!nather
                                       Astronomy Dept., U. of Texas, Austin

knop@dutesta.UUCP (Peter Knoppers) (04/04/84)

Main is called with 3 arguments. This is *not* an undocumented feature.
I quote from the manual page for exec(2):
------------

     When a C program is executed, it is called as follows:

          main(argc, argv, envp)
          int argc;
          char **argv, **envp;

------------
BTW, I do know of a U**X that doesn't support this. I maintain a slightly
hacked version of PWB/UNIX.  This UNIX version doesn't have environment
variables.

--
	Peter (If everything else fails, read the manuals) Knoppers.
	..!{decvax,philabs}!mcvax!dutesta!knop

sanders@aecom.UUCP (Jeremy Sanders) (04/06/84)

I've rarely seen the third argument of main() declared;  most  of
the  programs  I've  seen  use  external variable 'environ'.  Its
certainly a documented feature in system  III;  though  the  only
example I can think of off-hand is exec(2).  
-- 
					Jeremy Sanders
 {spike|rocky2|philabs|pegasus|esquire|cucard}!aecom!{sanders|jsanders|sander}

kvm@basser.SUN (Karlos Mauvtaque) (04/09/84)

All this heated "I've found something neat that nobody told us about"
is grotesque.  I take great delight in deleting undocumented sooterkins
from our libraries and watching those who like the mystique of something
picked up by word-of-mouth squirm and froth at the mouth.

liberte@uiucdcs.UUCP (04/13/84)

#R:hocda:-38700:uiucdcs:13700052:000:675
uiucdcs!liberte    Apr 13 11:33:00 1984

/**** uiucdcs:net.unix-wizar / basser!kvm /  6:52 pm  Apr 10, 1984 ****/
All this heated "I've found something neat that nobody told us about"
is grotesque.  I take great delight in deleting undocumented sooterkins
from our libraries and watching those who like the mystique of something
picked up by word-of-mouth squirm and froth at the mouth.
/* ---------- */


Alternatively, you could do a little more work and document these
"sooterkins" and watch more people squirm with delight.

UNIX, like adventure, makes discovery fun, but wondering around for hours
lost in the dungeon is *not* fun, or even profitable.

Daniel LaLiberte
University of Illinois, Urbana-Champaign

rde@ukc.UUCP (R.D.Eager) (04/14/84)

If you want to know what parameters a program is being passed, the manual
entry for exec(2) is NOT the most obvious place to look.  This has
always been a lack in the UNIX documentation.

    OK, OK, it is documented.  But what the hell use is it there????

     Bob Eager
     University of Kent at Canterbury, UK