summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/src/cmd/rc/glob.c8
-rw-r--r--sys/src/cmd/rc/plan9.c27
2 files changed, 13 insertions, 22 deletions
diff --git a/sys/src/cmd/rc/glob.c b/sys/src/cmd/rc/glob.c
index e52b420ee..00c9f7504 100644
--- a/sys/src/cmd/rc/glob.c
+++ b/sys/src/cmd/rc/glob.c
@@ -60,9 +60,15 @@ globdir(word *list, char *p, char *name, char *namep)
{
char *t, *newp;
int f;
- /* scan the pattern looking for a component with a metacharacter in it */
+
+ /* append slashes, Readdir() already filtered directories */
+ while(*p=='/'){
+ *namep++=*p++;
+ *namep='\0';
+ }
if(*p=='\0')
return newword(name, list);
+ /* scan the pattern looking for a component with a metacharacter in it */
t = namep;
newp = p;
while(*newp){
diff --git a/sys/src/cmd/rc/plan9.c b/sys/src/cmd/rc/plan9.c
index fd12e666c..4ac9a0bf7 100644
--- a/sys/src/cmd/rc/plan9.c
+++ b/sys/src/cmd/rc/plan9.c
@@ -345,23 +345,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 +367,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)
{