tset $samfile during external commands - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit c7c29d26b7f9bcd735779859211bf525f007078e
 (DIR) parent ca6a2d95acc005ef9a50e3f962ef0bbaa7876751
 (HTM) Author: rsc <devnull@localhost>
       Date:   Thu, 24 Aug 2006 18:37:55 +0000
       
       set $samfile during external commands
       
       Diffstat:
         M src/cmd/sam/shell.c                 |       9 +++++++++
       
       1 file changed, 9 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/sam/shell.c b/src/cmd/sam/shell.c
       t@@ -8,6 +8,14 @@ String        plan9cmd;        /* null terminated */
        Buffer        plan9buf;
        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
        plan9(File *f, int type, String *s, int nest)
        {
       t@@ -31,6 +39,7 @@ plan9(File *f, int type, String *s, int nest)
                if(type=='|')
                        snarf(f, addr.r.p1, addr.r.p2, &plan9buf, 1);
                if((pid=fork()) == 0){
       +                setname(f);
                        if(downloaded){        /* also put nasty fd's into errfile */
                                fd = create(errfile, 1, 0666L);
                                if(fd < 0)