env bug ?

Peter L. Peres plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org
Wed Mar 9 17:17:36 UTC 2005


On Wed, 9 Mar 2005, Lennart Sorensen wrote:

> Of course you still need to deal with the fact the filename gets passed
> as the last argument, which still makes this seem like not the place to
> use env.  #! is meant for running scripts with the correct interpreter,
> and nothing else.

And the correct interpreter is ... where exactly ? /usr/bin ? /bin ? 
/opt/bin ? some other place the suits at red hat & suse hided it at ?

I am not saying it should be called env, it could be called runscript. 
But it is needed I think. One should be able to say:

#!/bin/runscript -i -## pl -g goal -t halt -f

at the heading of a prolog program and have the obvious happen as long 
as pl is in the PATH. -## would mean 'prune all leading lines that begin 
with \'#\' from the script before passing it to the interpreter'. This 
would be done by runscript, which would copy its argv[2] to a temp 
file, starting with the first line that does not begin with the 
character indicated by its -# option. The effect of the above should be:

 	// lots of code omitted here, and code simplified below as an example
 	char *a = "/home/plp/bin/pl";
 	char *b[] = { "-g", "goal", "-f", "/tmp/_98987966.tmp", NULL };
 	char *myenv[] = { "PATH=/bin:/usr/bin", "USER=plp", "HOME=/home/plp", NULL };

 	r = execve( a, b, (seen_i)?myenv:environ ); // select env vs. -i option
 	if(r) {perror();}
 	exit(r);
} // main


Peter
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list