update to new fs
[unix-history] / usr / src / usr.bin / find / find.c
index a44075e..9ea5bc3 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)find.c      4.1 (Berkeley) %G%";
+static char *sccsid = "@(#)find.c      4.5 (Berkeley) %G%";
 /*     find    COMPILE:        cc -o find -s -O -i find.c -lS  */
 #include <stdio.h>
 #include <sys/types.h>
 /*     find    COMPILE:        cc -o find -s -O -i find.c -lS  */
 #include <stdio.h>
 #include <sys/types.h>
@@ -170,7 +170,7 @@ struct anode *e3() { /* parse parens and predicates */
                return(mk(atime, (struct anode *)atoi(b), (struct anode *)s));
        else if(EQ(a, "-user")) {
                if((i=getunum("/etc/passwd", b)) == -1) {
                return(mk(atime, (struct anode *)atoi(b), (struct anode *)s));
        else if(EQ(a, "-user")) {
                if((i=getunum("/etc/passwd", b)) == -1) {
-                       if(gmatch(b, "[0-9][0-9]*"))
+                       if(gmatch(b, "[0-9]*"))
                                return mk(user, (struct anode *)atoi(b), (struct anode *)s);
                        fprintf(stderr, "find: cannot find -user name\n");
                        exit(1);
                                return mk(user, (struct anode *)atoi(b), (struct anode *)s);
                        fprintf(stderr, "find: cannot find -user name\n");
                        exit(1);
@@ -181,7 +181,7 @@ struct anode *e3() { /* parse parens and predicates */
                return(mk(ino, (struct anode *)atoi(b), (struct anode *)s));
        else if(EQ(a, "-group")) {
                if((i=getunum("/etc/group", b)) == -1) {
                return(mk(ino, (struct anode *)atoi(b), (struct anode *)s));
        else if(EQ(a, "-group")) {
                if((i=getunum("/etc/group", b)) == -1) {
-                       if(gmatch(b, "[0-9][0-9]*"))
+                       if(gmatch(b, "[0-9]*"))
                                return mk(group, (struct anode *)atoi(b), (struct anode *)s);
                        fprintf(stderr, "find: cannot find -group name\n");
                        exit(1);
                                return mk(group, (struct anode *)atoi(b), (struct anode *)s);
                        fprintf(stderr, "find: cannot find -group name\n");
                        exit(1);
@@ -456,8 +456,14 @@ doex(com)
        }
        nargv[np] = 0;
        if (np==0) return(9);
        }
        nargv[np] = 0;
        if (np==0) return(9);
-       if(fork()) /*parent*/ wait(&ccode);
-       else { /*child*/
+       if(fork()) /*parent*/ {
+#include <signal.h>
+               int (*old)() = signal(SIGINT, SIG_IGN);
+               int (*oldq)() = signal(SIGQUIT, SIG_IGN);
+               wait(&ccode);
+               signal(SIGINT, old);
+               signal(SIGQUIT, oldq);
+       } else { /*child*/
                chdir(Home);
                execvp(nargv[0], nargv, np);
                exit(1);
                chdir(Home);
                execvp(nargv[0], nargv, np);
                exit(1);
@@ -513,7 +519,7 @@ char *name, *fname;
        int rv = 0;
        char *endofname;
 
        int rv = 0;
        char *endofname;
 
-       if(stat(fname, &Statb)<0) {
+       if(lstat(fname, &Statb)<0) {
                fprintf(stderr, "find: bad status < %s >\n", name);
                return(0);
        }
                fprintf(stderr, "find: bad status < %s >\n", name);
                return(0);
        }