Path: utzoo!mnetor!uunet!munnari!otc!metro!basser!elecvax!spinifex!neilb
From: neilb@spinifex.unsw.oz (Neil Brown)
Newsgroups: comp.unix.wizards
Subject: Re: globbing in the shell - let the shell handle it
Message-ID: <455@spinifex.unsw.oz>
Date: 7 Dec 87 23:14:16 GMT
References: <1257@boulder.Colorado.EDU> <6840002@hpcllmv.HP.COM> <1475@osiris.UUCP>
Organization: EE & CS, Uni N.S.W., Sydney, Australia
Lines: 39
Summary: CMDLINE=??? wont work...


I see a small problem with passing a program is pre-parsed command line
in an environment variable.

Consider:

% whiz-bang -lot -of -strnge *.x arguments

 in whiz-bang
	if (fork()==0)
		execl("/bin/rm","rm","-r",tempdir,0L),exit(1);
				/* remove my temporary directory */

	    inside rm
		look at argv
		look at CMDLINE
			They're SO different, what sort
			of shell is THIS charlie using.
			 But are they REALLY different, or is it
			some obscure substitution, I'll just check
			 "this wont take long guys" > /dev/tty
			 .......


You see, the environment gets inherited beyond the first process.
Of course you could do something like
	sprintf(envline,"CMDLINE%d=%s",getpid(),cmdline);
	( after fork, before exec)

	and getenv(strcat("CMDLINE",itoa(getpid()))) /* sort of */

but it gets uglier by the minute.

A thought I just had..
Maybe if rm started asking questions if any of the named files didn't exist.
This would catch  * .o type error as .o probably wouldn't exist.... just a
thought

NeilBrown