]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/cmd/rc/plan9.c
git/branch: somewhere in the syncing, the fix for junk files was lost
[plan9front.git] / sys / src / cmd / rc / plan9.c
index fd12e666c94f604e056359fed78143e3bc3be73a..634570c26fb93ba63239b75976b6b32220348efa 100644 (file)
@@ -164,9 +164,12 @@ Xrdfn(void)
        if(runq->argv->words == 0)
                poplist();
        else {
+               free(runq->cmdfile);
                int f = open(runq->argv->words->word, 0);
-               popword();
+               lexline = 0;
+               runq->cmdfile = strdup(runq->argv->words->word);
                runq->pc--;
+               popword();
                if(f>=0) execcmds(openfd(f));
        }
 }
@@ -345,23 +348,15 @@ struct{
 int
 Opendir(char *name)
 {
-       Dir *db;
        int f;
-       f = open(name, 0);
-       if(f==-1)
-               return f;
-       db = dirfstat(f);
-       if(db!=nil && (db->mode&DMDIR)){
-               if(f<NFD){
-                       dir[f].i = 0;
-                       dir[f].n = 0;
-               }
-               free(db);
+
+       if((f = open(name, 0)) < 0)
                return f;
+       if(f<NFD){
+               dir[f].i = 0;
+               dir[f].n = 0;
        }
-       free(db);
-       close(f);
-       return -1;
+       return f;
 }
 
 static int
@@ -375,13 +370,6 @@ trimdirs(Dir *d, int nd)
        return w;
 }
 
-/*
- * onlydirs is advisory -- it means you only
- * need to return the directories.  it's okay to
- * return files too (e.g., on unix where you can't
- * tell during the readdir), but that just makes 
- * the globber work harder.
- */
 int
 Readdir(int f, void *p, int onlydirs)
 {