set $samfile during external commands

This commit is contained in:
rsc 2006-08-24 18:37:55 +00:00
parent ca6a2d95ac
commit c7c29d26b7

View file

@ -8,6 +8,14 @@ String plan9cmd; /* null terminated */
Buffer plan9buf; Buffer plan9buf;
void checkerrs(void); void checkerrs(void);
void
setname(File *f)
{
char buf[1024];
snprint(buf, sizeof buf, "%.*S", f->name.n, f->name.s);
putenv("samfile", buf);
}
int int
plan9(File *f, int type, String *s, int nest) plan9(File *f, int type, String *s, int nest)
{ {
@ -31,6 +39,7 @@ plan9(File *f, int type, String *s, int nest)
if(type=='|') if(type=='|')
snarf(f, addr.r.p1, addr.r.p2, &plan9buf, 1); snarf(f, addr.r.p1, addr.r.p2, &plan9buf, 1);
if((pid=fork()) == 0){ if((pid=fork()) == 0){
setname(f);
if(downloaded){ /* also put nasty fd's into errfile */ if(downloaded){ /* also put nasty fd's into errfile */
fd = create(errfile, 1, 0666L); fd = create(errfile, 1, 0666L);
if(fd < 0) if(fd < 0)