aboutsummaryrefslogtreecommitdiff
path: root/findutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-07-25 10:41:42 +0100
committerRon Yorston <rmy@pobox.com>2018-07-25 10:41:42 +0100
commit59873514f17cefd6ba3997dad5779f75433fd4e6 (patch)
tree1c9d0a3450ed95f0b820285b9f9fc217c902e652 /findutils
parent779fd5745ac11bf752f5f4b977a274a39c192f90 (diff)
parent81de30de05beebabfa72f2a01ec4f33e9a1923e3 (diff)
downloadbusybox-w32-59873514f17cefd6ba3997dad5779f75433fd4e6.tar.gz
busybox-w32-59873514f17cefd6ba3997dad5779f75433fd4e6.tar.bz2
busybox-w32-59873514f17cefd6ba3997dad5779f75433fd4e6.zip
Merge branch 'busybox'
Diffstat (limited to 'findutils')
-rw-r--r--findutils/Config.src2
-rw-r--r--findutils/find.c56
-rw-r--r--findutils/grep.c11
-rw-r--r--findutils/xargs.c2
4 files changed, 62 insertions, 9 deletions
diff --git a/findutils/Config.src b/findutils/Config.src
index 9ee71a845..c28c5844e 100644
--- a/findutils/Config.src
+++ b/findutils/Config.src
@@ -1,6 +1,6 @@
1# 1#
2# For a description of the syntax of this configuration file, 2# For a description of the syntax of this configuration file,
3# see scripts/kbuild/config-language.txt. 3# see docs/Kconfig-language.txt.
4# 4#
5 5
6menu "Finding Utilities" 6menu "Finding Utilities"
diff --git a/findutils/find.c b/findutils/find.c
index 07321c81a..6407c6c5a 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -95,6 +95,11 @@
95//config: Enable searching based on file type (file, 95//config: Enable searching based on file type (file,
96//config: directory, socket, device, etc.). 96//config: directory, socket, device, etc.).
97//config: 97//config:
98//config:config FEATURE_FIND_EXECUTABLE
99//config: bool "Enable -executable: file is executable"
100//config: default y
101//config: depends on FIND
102//config:
98//config:config FEATURE_FIND_XDEV 103//config:config FEATURE_FIND_XDEV
99//config: bool "Enable -xdev: 'stay in filesystem'" 104//config: bool "Enable -xdev: 'stay in filesystem'"
100//config: default y 105//config: default y
@@ -182,6 +187,13 @@
182//config: If the file is a directory, don't descend into it. Useful for 187//config: If the file is a directory, don't descend into it. Useful for
183//config: exclusion .svn and CVS directories. 188//config: exclusion .svn and CVS directories.
184//config: 189//config:
190//config:config FEATURE_FIND_QUIT
191//config: bool "Enable -quit: exit"
192//config: default y
193//config: depends on FIND
194//config: help
195//config: If this action is reached, 'find' exits.
196//config:
185//config:config FEATURE_FIND_DELETE 197//config:config FEATURE_FIND_DELETE
186//config: bool "Enable -delete: delete files/dirs" 198//config: bool "Enable -delete: delete files/dirs"
187//config: default y 199//config: default y
@@ -265,6 +277,9 @@
265//usage: IF_FEATURE_FIND_TYPE( 277//usage: IF_FEATURE_FIND_TYPE(
266//usage: "\n -type X File type is X (one of: f,d,l,b,c,s,p)" 278//usage: "\n -type X File type is X (one of: f,d,l,b,c,s,p)"
267//usage: ) 279//usage: )
280//usage: IF_FEATURE_FIND_EXECUTABLE(
281//usage: "\n -executable File is executable"
282//usage: )
268//usage: IF_FEATURE_FIND_PERM( 283//usage: IF_FEATURE_FIND_PERM(
269//usage: "\n -perm MASK At least one mask bit (+MASK), all bits (-MASK)," 284//usage: "\n -perm MASK At least one mask bit (+MASK), all bits (-MASK),"
270//usage: "\n or exactly MASK bits are set in file's mode" 285//usage: "\n or exactly MASK bits are set in file's mode"
@@ -318,6 +333,9 @@
318//usage: IF_FEATURE_FIND_DELETE( 333//usage: IF_FEATURE_FIND_DELETE(
319//usage: "\n -delete Delete current file/directory. Turns on -depth option" 334//usage: "\n -delete Delete current file/directory. Turns on -depth option"
320//usage: ) 335//usage: )
336//usage: IF_FEATURE_FIND_QUIT(
337//usage: "\n -quit Exit"
338//usage: )
321//usage: 339//usage:
322//usage:#define find_example_usage 340//usage:#define find_example_usage
323//usage: "$ find / -name passwd\n" 341//usage: "$ find / -name passwd\n"
@@ -365,6 +383,7 @@ IF_FEATURE_FIND_PATH( ACTS(path, const char *pattern; bool ipath;))
365IF_FEATURE_FIND_REGEX( ACTS(regex, regex_t compiled_pattern;)) 383IF_FEATURE_FIND_REGEX( ACTS(regex, regex_t compiled_pattern;))
366IF_FEATURE_FIND_PRINT0( ACTS(print0)) 384IF_FEATURE_FIND_PRINT0( ACTS(print0))
367IF_FEATURE_FIND_TYPE( ACTS(type, int type_mask;)) 385IF_FEATURE_FIND_TYPE( ACTS(type, int type_mask;))
386IF_FEATURE_FIND_EXECUTABLE(ACTS(executable))
368IF_FEATURE_FIND_PERM( ACTS(perm, char perm_char; mode_t perm_mask;)) 387IF_FEATURE_FIND_PERM( ACTS(perm, char perm_char; mode_t perm_mask;))
369IF_FEATURE_FIND_MTIME( ACTS(mtime, char mtime_char; unsigned mtime_days;)) 388IF_FEATURE_FIND_MTIME( ACTS(mtime, char mtime_char; unsigned mtime_days;))
370IF_FEATURE_FIND_MMIN( ACTS(mmin, char mmin_char; unsigned mmin_mins;)) 389IF_FEATURE_FIND_MMIN( ACTS(mmin, char mmin_char; unsigned mmin_mins;))
@@ -375,6 +394,7 @@ IF_FEATURE_FIND_SIZE( ACTS(size, char size_char; off_t size;))
375IF_FEATURE_FIND_CONTEXT(ACTS(context, security_context_t context;)) 394IF_FEATURE_FIND_CONTEXT(ACTS(context, security_context_t context;))
376IF_FEATURE_FIND_PAREN( ACTS(paren, action ***subexpr;)) 395IF_FEATURE_FIND_PAREN( ACTS(paren, action ***subexpr;))
377IF_FEATURE_FIND_PRUNE( ACTS(prune)) 396IF_FEATURE_FIND_PRUNE( ACTS(prune))
397IF_FEATURE_FIND_QUIT( ACTS(quit))
378IF_FEATURE_FIND_DELETE( ACTS(delete)) 398IF_FEATURE_FIND_DELETE( ACTS(delete))
379IF_FEATURE_FIND_EXEC( ACTS(exec, 399IF_FEATURE_FIND_EXEC( ACTS(exec,
380 char **exec_argv; /* -exec ARGS */ 400 char **exec_argv; /* -exec ARGS */
@@ -402,6 +422,7 @@ struct globals {
402 action ***actions; 422 action ***actions;
403 smallint need_print; 423 smallint need_print;
404 smallint xdev_on; 424 smallint xdev_on;
425 smalluint exitstatus;
405 recurse_flags_t recurse_flags; 426 recurse_flags_t recurse_flags;
406 IF_FEATURE_FIND_EXEC_PLUS(unsigned max_argv_len;) 427 IF_FEATURE_FIND_EXEC_PLUS(unsigned max_argv_len;)
407} FIX_ALIASING; 428} FIX_ALIASING;
@@ -566,6 +587,12 @@ ACTF(type)
566 return ((statbuf->st_mode & S_IFMT) == ap->type_mask); 587 return ((statbuf->st_mode & S_IFMT) == ap->type_mask);
567} 588}
568#endif 589#endif
590#if ENABLE_FEATURE_FIND_EXECUTABLE
591ACTF(executable)
592{
593 return access(fileName, X_OK) == 0;
594}
595#endif
569#if ENABLE_FEATURE_FIND_PERM 596#if ENABLE_FEATURE_FIND_PERM
570ACTF(perm) 597ACTF(perm)
571{ 598{
@@ -774,6 +801,12 @@ ACTF(prune)
774 return SKIP + TRUE; 801 return SKIP + TRUE;
775} 802}
776#endif 803#endif
804#if ENABLE_FEATURE_FIND_QUIT
805ACTF(quit)
806{
807 exit(G.exitstatus);
808}
809#endif
777#if ENABLE_FEATURE_FIND_DELETE 810#if ENABLE_FEATURE_FIND_DELETE
778ACTF(delete) 811ACTF(delete)
779{ 812{
@@ -954,8 +987,10 @@ static action*** parse_params(char **argv)
954 PARM_print , 987 PARM_print ,
955 IF_FEATURE_FIND_PRINT0( PARM_print0 ,) 988 IF_FEATURE_FIND_PRINT0( PARM_print0 ,)
956 IF_FEATURE_FIND_PRUNE( PARM_prune ,) 989 IF_FEATURE_FIND_PRUNE( PARM_prune ,)
990 IF_FEATURE_FIND_QUIT( PARM_quit ,)
957 IF_FEATURE_FIND_DELETE( PARM_delete ,) 991 IF_FEATURE_FIND_DELETE( PARM_delete ,)
958 IF_FEATURE_FIND_EXEC( PARM_exec ,) 992 IF_FEATURE_FIND_EXEC( PARM_exec ,)
993 IF_FEATURE_FIND_EXECUTABLE(PARM_executable,)
959 IF_FEATURE_FIND_PAREN( PARM_char_brace,) 994 IF_FEATURE_FIND_PAREN( PARM_char_brace,)
960 /* All options/actions starting from here require argument */ 995 /* All options/actions starting from here require argument */
961 PARM_name , 996 PARM_name ,
@@ -997,8 +1032,10 @@ static action*** parse_params(char **argv)
997 "-print\0" 1032 "-print\0"
998 IF_FEATURE_FIND_PRINT0( "-print0\0" ) 1033 IF_FEATURE_FIND_PRINT0( "-print0\0" )
999 IF_FEATURE_FIND_PRUNE( "-prune\0" ) 1034 IF_FEATURE_FIND_PRUNE( "-prune\0" )
1035 IF_FEATURE_FIND_QUIT( "-quit\0" )
1000 IF_FEATURE_FIND_DELETE( "-delete\0" ) 1036 IF_FEATURE_FIND_DELETE( "-delete\0" )
1001 IF_FEATURE_FIND_EXEC( "-exec\0" ) 1037 IF_FEATURE_FIND_EXEC( "-exec\0" )
1038 IF_FEATURE_FIND_EXECUTABLE("-executable\0")
1002 IF_FEATURE_FIND_PAREN( "(\0" ) 1039 IF_FEATURE_FIND_PAREN( "(\0" )
1003 /* All options/actions starting from here require argument */ 1040 /* All options/actions starting from here require argument */
1004 "-name\0" 1041 "-name\0"
@@ -1152,6 +1189,12 @@ static action*** parse_params(char **argv)
1152 (void) ALLOC_ACTION(prune); 1189 (void) ALLOC_ACTION(prune);
1153 } 1190 }
1154#endif 1191#endif
1192#if ENABLE_FEATURE_FIND_QUIT
1193 else if (parm == PARM_quit) {
1194 dbg("%d", __LINE__);
1195 (void) ALLOC_ACTION(quit);
1196 }
1197#endif
1155#if ENABLE_FEATURE_FIND_DELETE 1198#if ENABLE_FEATURE_FIND_DELETE
1156 else if (parm == PARM_delete) { 1199 else if (parm == PARM_delete) {
1157 dbg("%d", __LINE__); 1200 dbg("%d", __LINE__);
@@ -1262,6 +1305,11 @@ static action*** parse_params(char **argv)
1262 dbg("created:type mask:%x", ap->type_mask); 1305 dbg("created:type mask:%x", ap->type_mask);
1263 } 1306 }
1264#endif 1307#endif
1308#if ENABLE_FEATURE_FIND_EXECUTABLE
1309 else if (parm == PARM_executable) {
1310 (void) ALLOC_ACTION(executable);
1311 }
1312#endif
1265#if ENABLE_FEATURE_FIND_PERM 1313#if ENABLE_FEATURE_FIND_PERM
1266/* -perm BITS File's mode bits are exactly BITS (octal or symbolic). 1314/* -perm BITS File's mode bits are exactly BITS (octal or symbolic).
1267 * Symbolic modes use mode 0 as a point of departure. 1315 * Symbolic modes use mode 0 as a point of departure.
@@ -1401,7 +1449,7 @@ static action*** parse_params(char **argv)
1401int find_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 1449int find_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
1402int find_main(int argc UNUSED_PARAM, char **argv) 1450int find_main(int argc UNUSED_PARAM, char **argv)
1403{ 1451{
1404 int i, firstopt, status = EXIT_SUCCESS; 1452 int i, firstopt;
1405 char **past_HLP, *saved; 1453 char **past_HLP, *saved;
1406 1454
1407 INIT_G(); 1455 INIT_G();
@@ -1475,10 +1523,10 @@ int find_main(int argc UNUSED_PARAM, char **argv)
1475 NULL, /* user data */ 1523 NULL, /* user data */
1476 0) /* depth */ 1524 0) /* depth */
1477 ) { 1525 ) {
1478 status |= EXIT_FAILURE; 1526 G.exitstatus |= EXIT_FAILURE;
1479 } 1527 }
1480 } 1528 }
1481 1529
1482 IF_FEATURE_FIND_EXEC_PLUS(status |= flush_exec_plus();) 1530 IF_FEATURE_FIND_EXEC_PLUS(G.exitstatus |= flush_exec_plus();)
1483 return status; 1531 return G.exitstatus;
1484} 1532}
diff --git a/findutils/grep.c b/findutils/grep.c
index 88de0d4ef..3e8ea9239 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -704,10 +704,15 @@ int grep_main(int argc UNUSED_PARAM, char **argv)
704 /* do normal option parsing */ 704 /* do normal option parsing */
705#if ENABLE_FEATURE_GREP_CONTEXT 705#if ENABLE_FEATURE_GREP_CONTEXT
706 /* -H unsets -h; -C unsets -A,-B */ 706 /* -H unsets -h; -C unsets -A,-B */
707 opts = getopt32(argv, 707 opts = getopt32long(argv, "^"
708 "^" OPTSTR_GREP "\0" "H-h:C-AB", 708 OPTSTR_GREP
709 "\0"
710 "H-h:C-AB",
711 "color\0" Optional_argument "\xff",
709 &pattern_head, &fopt, &max_matches, 712 &pattern_head, &fopt, &max_matches,
710 &lines_after, &lines_before, &Copt); 713 &lines_after, &lines_before, &Copt
714 , NULL
715 );
711 716
712 if (opts & OPT_C) { 717 if (opts & OPT_C) {
713 /* -C unsets prev -A and -B, but following -A or -B 718 /* -C unsets prev -A and -B, but following -A or -B
diff --git a/findutils/xargs.c b/findutils/xargs.c
index df2300207..4399783ea 100644
--- a/findutils/xargs.c
+++ b/findutils/xargs.c
@@ -606,7 +606,7 @@ static int xargs_ask_confirmation(void)
606//usage: ) 606//usage: )
607//usage: "\n -r Don't run command if input is empty" 607//usage: "\n -r Don't run command if input is empty"
608//usage: IF_FEATURE_XARGS_SUPPORT_ZERO_TERM( 608//usage: IF_FEATURE_XARGS_SUPPORT_ZERO_TERM(
609//usage: "\n -0 Input is separated by NUL characters" 609//usage: "\n -0 Input is separated by NULs"
610//usage: ) 610//usage: )
611//usage: IF_FEATURE_XARGS_SUPPORT_ARGS_FILE( 611//usage: IF_FEATURE_XARGS_SUPPORT_ARGS_FILE(
612//usage: "\n -a FILE Read from FILE instead of stdin" 612//usage: "\n -a FILE Read from FILE instead of stdin"