This commit was manufactured by cvs2svn to create tag 'FreeBSD-release/1.0'.
[unix-history] / usr.bin / find / main.c
index 114e8ef..073a5f0 100644 (file)
@@ -1,6 +1,6 @@
 /*-
 /*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.9 (Berkeley) 5/24/91";
+static char sccsid[] = "@(#)main.c     8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
 #include <sys/types.h>
 #include <sys/stat.h>
 #endif /* not lint */
 
 #include <sys/types.h>
 #include <sys/stat.h>
+
+#include <err.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <fcntl.h>
-#include <time.h>
 #include <fts.h>
 #include <fts.h>
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <time.h>
+
 #include "find.h"
 
 time_t now;                    /* time find was run */
 #include "find.h"
 
 time_t now;                    /* time find was run */
@@ -53,29 +56,32 @@ int isdepth;                        /* do directories on post-order visit */
 int isoutput;                  /* user specified output operator */
 int isxargs;                   /* don't permit xargs delimiting chars */
 
 int isoutput;                  /* user specified output operator */
 int isxargs;                   /* don't permit xargs delimiting chars */
 
-static void usage();
+static void usage __P((void));
 
 
+int
 main(argc, argv)
        int argc;
 main(argc, argv)
        int argc;
-       char **argv;
+       char *argv[];
 {
        register char **p, **start;
 {
        register char **p, **start;
-       PLAN *find_formplan();
        int ch;
 
        (void)time(&now);       /* initialize the time-of-day */
 
        p = start = argv;
        ftsoptions = FTS_NOSTAT|FTS_PHYSICAL;
        int ch;
 
        (void)time(&now);       /* initialize the time-of-day */
 
        p = start = argv;
        ftsoptions = FTS_NOSTAT|FTS_PHYSICAL;
-       while ((ch = getopt(argc, argv, "df:sXx")) != EOF)
+       while ((ch = getopt(argc, argv, "Hdf:hXx")) != EOF)
                switch(ch) {
                switch(ch) {
+               case 'H':
+                       ftsoptions |= FTS_COMFOLLOW;
+                       break;
                case 'd':
                        isdepth = 1;
                        break;
                case 'f':
                        *p++ = optarg;
                        break;
                case 'd':
                        isdepth = 1;
                        break;
                case 'f':
                        *p++ = optarg;
                        break;
-               case 's':
+               case 'h':
                        ftsoptions &= ~FTS_PHYSICAL;
                        ftsoptions |= FTS_LOGICAL;
                        break;
                        ftsoptions &= ~FTS_PHYSICAL;
                        ftsoptions |= FTS_LOGICAL;
                        break;
@@ -83,7 +89,6 @@ main(argc, argv)
                        isxargs = 1;
                        break;
                case 'x':
                        isxargs = 1;
                        break;
                case 'x':
-                       ftsoptions &= ~FTS_NOSTAT;
                        ftsoptions |= FTS_XDEV;
                        break;
                case '?':
                        ftsoptions |= FTS_XDEV;
                        break;
                case '?':
@@ -106,15 +111,25 @@ main(argc, argv)
        *p = NULL;
 
        if ((dotfd = open(".", O_RDONLY, 0)) < 0)
        *p = NULL;
 
        if ((dotfd = open(".", O_RDONLY, 0)) < 0)
-               err(".: %s", strerror(errno));
+               err(1, ".:");
 
        find_execute(find_formplan(argv), start);
 
        find_execute(find_formplan(argv), start);
+       exit(0);
 }
 
 static void
 usage()
 {
        (void)fprintf(stderr,
 }
 
 static void
 usage()
 {
        (void)fprintf(stderr,
-           "usage: find [-dsXx] [-f file] [file ...] expression\n");
+           "usage: find [-HdhXx] [-f file] [file ...] expression\n");
        exit(1);
 }
        exit(1);
 }
+
+
+
+
+
+
+
+
+