SCCS-vsn: usr.bin/find/find.1 6.20
SCCS-vsn: usr.bin/find/find.c 4.37
SCCS-vsn: usr.bin/find/find.h 5.6
SCCS-vsn: usr.bin/find/main.c 5.7
.\"
.\" %sccs.include.redist.man%
.\"
.\"
.\" %sccs.include.redist.man%
.\"
-.\" @(#)find.1 6.19 (Berkeley) %G%
+.\" @(#)find.1 6.20 (Berkeley) %G%
.Nd walk a file hierarchy
.Sh SYNOPSIS
.Nm find
.Nd walk a file hierarchy
.Sh SYNOPSIS
.Nm find
.Op Ar path
.Ar expression
.Nm find
.Op Ar path
.Ar expression
.Nm find
link, not the link itself.
If the referenced file does not exist, the file information and type will
be for the link itself.
link, not the link itself.
If the referenced file does not exist, the file information and type will
be for the link itself.
+.Tp Fl X
+The
+.Fl X
+option is a modification to permit
+.Nm
+to be safely used in conjunction with
+.Xr xargs 1 .
+If a file name contains any of the delimiting characters used by
+.Xr xargs ,
+a diagnostic message is displayed on standard error, and the file
+is skipped.
+The delimiting characters include single (`` ' '') and double (`` " '')
+quotes, backslash (``\e''), space, tab and newline characters.
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)find.c 4.36 (Berkeley) %G%";
+static char sccsid[] = "@(#)find.c 4.37 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
int isdepth; /* do directories on post-order visit */
int isoutput; /* user specified output operator */
int isrelative; /* can do -exec/ok on relative path */
int isdepth; /* do directories on post-order visit */
int isoutput; /* user specified output operator */
int isrelative; /* can do -exec/ok on relative path */
+int isxargs; /* don't permit xargs delimiting chars */
main(argc, argv)
int argc;
main(argc, argv)
int argc;
+#define BADCH " \t\n\\'\""
+ if (isxargs && strpbrk(entry->fts_path, BADCH)) {
+ (void)fprintf(stderr,
+ "find: illegal path: %s\n", entry->fts_path);
+ continue;
+ }
+
/*
* call all the functions in the execution plan until one is
* false or all have been executed. This is where we do all
/*
* call all the functions in the execution plan until one is
* false or all have been executed. This is where we do all
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)find.h 5.5 (Berkeley) %G%
+ * @(#)find.h 5.6 (Berkeley) %G%
(void)fprintf(stderr, "find: %s: %s\n", name, strerror(number));
extern int ftsoptions;
(void)fprintf(stderr, "find: %s: %s\n", name, strerror(number));
extern int ftsoptions;
-extern int isdeprecated, isdepth, isoutput, isrelative;
+extern int isdeprecated, isdepth, isoutput, isrelative, isxargs;
-static char sccsid[] = "@(#)main.c 5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c 5.7 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
char **argv, **cur;
cur = argv = *argvp;
char **argv, **cur;
cur = argv = *argvp;
- while ((ch = getopt(argc, argv, "df:rsx")) != EOF)
+ while ((ch = getopt(argc, argv, "df:rsXx")) != EOF)
switch(ch) {
case 'd':
isdepth = 1;
switch(ch) {
case 'd':
isdepth = 1;
ftsoptions &= ~FTS_PHYSICAL;
ftsoptions |= FTS_LOGICAL;
break;
ftsoptions &= ~FTS_PHYSICAL;
ftsoptions |= FTS_LOGICAL;
break;
+ case 'X':
+ isxargs = 1;
+ break;
case 'x':
ftsoptions &= ~FTS_NOSTAT;
ftsoptions |= FTS_XDEV;
case 'x':
ftsoptions &= ~FTS_NOSTAT;
ftsoptions |= FTS_XDEV;