svn commit: trunk/busybox: findutils include
pgf at busybox.net
pgf at busybox.net
Fri May 12 14:47:22 UTC 2006
Author: pgf
Date: 2006-05-12 07:47:20 -0700 (Fri, 12 May 2006)
New Revision: 15076
Log:
implement -print0 for find
Modified:
trunk/busybox/findutils/Config.in
trunk/busybox/findutils/find.c
trunk/busybox/include/usage.h
Changeset:
Modified: trunk/busybox/findutils/Config.in
===================================================================
--- trunk/busybox/findutils/Config.in 2006-05-12 03:28:13 UTC (rev 15075)
+++ trunk/busybox/findutils/Config.in 2006-05-12 14:47:20 UTC (rev 15076)
@@ -11,6 +11,16 @@
help
find is used to search your system to find specified files.
+config CONFIG_FEATURE_FIND_PRINT0
+ bool "Enable -print0 option"
+ default y
+ depends on CONFIG_FIND
+ help
+ Causes output names to be separated by a null character
+ rather than a newline. This allows names that contain
+ newlines and other whitespace to be more easily
+ interpreted by other programs.
+
config CONFIG_FEATURE_FIND_MTIME
bool "Enable modified time matching (-mtime) option"
default y
Modified: trunk/busybox/findutils/find.c
===================================================================
--- trunk/busybox/findutils/find.c 2006-05-12 03:28:13 UTC (rev 15075)
+++ trunk/busybox/findutils/find.c 2006-05-12 14:47:20 UTC (rev 15076)
@@ -38,6 +38,9 @@
static const char msg_invalid_arg[] = "invalid argument `%s' to `%s'";
static char *pattern;
+#ifdef CONFIG_FEATURE_FIND_PRINT0
+static char printsep = '\n';
+#endif
#ifdef CONFIG_FEATURE_FIND_TYPE
static int type_mask = 0;
@@ -159,7 +162,11 @@
}
#endif
+#ifdef CONFIG_FEATURE_FIND_PRINT0
+ printf("%s%c", fileName, printsep);
+#else
puts(fileName);
+#endif
no_match:
return (TRUE);
}
@@ -217,6 +224,10 @@
else if (strcmp(argv[i], "-print") == 0) {
;
}
+#ifdef CONFIG_FEATURE_FIND_PRINT0
+ else if (strcmp(argv[i], "-print0") == 0)
+ printsep = '\0';
+#endif
else if (strcmp(argv[i], "-name") == 0) {
if (++i == argc)
bb_error_msg_and_die(msg_req_arg, "-name");
Modified: trunk/busybox/include/usage.h
===================================================================
--- trunk/busybox/include/usage.h 2006-05-12 03:28:13 UTC (rev 15075)
+++ trunk/busybox/include/usage.h 2006-05-12 14:47:20 UTC (rev 15076)
@@ -748,7 +748,9 @@
"\t-follow\t\tDereference symbolic links\n" \
"\t-name PATTERN\tFile name (leading directories removed) matches PATTERN\n" \
"\t-print\t\tPrint (default and assumed)\n" \
- USE_FEATURE_FIND_TYPE( \
+ USE_FEATURE_FIND_PRINT0( \
+ "\t-print0\t\tDelimit output with null characters rather than\n\t\t\tnewlines" \
+) USE_FEATURE_FIND_TYPE( \
"\n\t-type X\t\tFiletype matches X (where X is one of: f,d,l,b,c,...)" \
) USE_FEATURE_FIND_PERM( \
"\n\t-perm PERMS\tPermissions match any of (+NNN); all of (-NNN);\n\t\t\tor exactly (NNN)" \
More information about the busybox-cvs
mailing list