Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!husc6!bloom-beacon!athena.mit.edu!eichin
From: eichin@athena.mit.edu (Mark W. Eichin)
Newsgroups: comp.unix.wizards
Subject: Re: globbing in the shell (Was Re: more rm insanity)
Message-ID: <1966@bloom-beacon.MIT.EDU>
Date: Sat, 5-Dec-87 10:16:56 EST
Article-I.D.: bloom-be.1966
Posted: Sat Dec  5 10:16:56 1987
Date-Received: Thu, 10-Dec-87 05:44:23 EST
References: <1257@boulder.Colorado.EDU> <6840002@hpcllmv.HP.COM>
Sender: daemon@bloom-beacon.MIT.EDU
Reply-To: eichin@athena.mit.edu (Mark W. Eichin)
Organization: Mainlining Indian Tea...
Lines: 32

Rather than
> int main(int argc, char *argv[], char *command_line);
I believe the un!x main is already of the form
  int main(int argc, char *argv[], char *environ[]);
(this is from the 4.3BSD man page for execl(3), rewritten as a prototype)
Since we are talking about `system people' I assume we are not concerned
with ANSI but with existing stuff.

Why break anything, when you could just pass an environment variable
in?  This would mean a modified exec, by wrapping something around it
in the C library... then the child could do a getenv("INVOCATION"), and
you could perhaps use this in shell scripts too.

In fact...

execve(name, argv, envp)
	char *name, *argv[], *envp[];	/* from execve(2) man page */
{
	setenv(envp, "INVOCATION", name);
	return(real_execve(name, argv, envp));
}

is all you would need [the syntax for setenv should be obvious and the
code is left as an exercise for the reader :-] to experiment with the
idea.

				Mark Eichin
				

Disclaimer: The opinions and indenting style in this posting are mine,
and not those of MIT or Project Athena. Of course, you can't prove
they are mine, either... scary, isn't it.