aboutsummaryrefslogtreecommitdiff
path: root/findutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-06-15 15:40:16 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-06-15 15:40:16 +0200
commit4f731ce30ec2a9f5e9b231b47aa68f32b75feb35 (patch)
treef63b07e88c4f31b4b3d1b5a1deeac971785158e6 /findutils
parentc37fecb86c52da9e2781ee9eeb90d5d8894f59e0 (diff)
downloadbusybox-w32-4f731ce30ec2a9f5e9b231b47aa68f32b75feb35.tar.gz
busybox-w32-4f731ce30ec2a9f5e9b231b47aa68f32b75feb35.tar.bz2
busybox-w32-4f731ce30ec2a9f5e9b231b47aa68f32b75feb35.zip
findutils/*: move usage and applet bits to *.c files
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'findutils')
-rw-r--r--findutils/find.c90
-rw-r--r--findutils/grep.c63
-rw-r--r--findutils/xargs.c27
3 files changed, 172 insertions, 8 deletions
diff --git a/findutils/find.c b/findutils/find.c
index ca630b6c5..297081489 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -53,8 +53,10 @@
53 * diff -u /tmp/std_find /tmp/bb_find && echo Identical 53 * diff -u /tmp/std_find /tmp/bb_find && echo Identical
54 */ 54 */
55 55
56//applet:IF_FIND(APPLET_NOEXEC(find, find, _BB_DIR_USR_BIN, _BB_SUID_DROP, find))
57
56//kbuild:lib-$(CONFIG_FIND) += find.o 58//kbuild:lib-$(CONFIG_FIND) += find.o
57//config: 59
58//config:config FIND 60//config:config FIND
59//config: bool "find" 61//config: bool "find"
60//config: default y 62//config: default y
@@ -1044,6 +1046,92 @@ static action*** parse_params(char **argv)
1044#undef ALLOC_ACTION 1046#undef ALLOC_ACTION
1045} 1047}
1046 1048
1049//usage:#define find_trivial_usage
1050//usage: "[PATH]... [EXPRESSION]"
1051//usage:#define find_full_usage "\n\n"
1052//usage: "Search for files. The default PATH is the current directory,\n"
1053//usage: "default EXPRESSION is '-print'\n"
1054//usage: "\nEXPRESSION may consist of:"
1055//usage: "\n -follow Follow symlinks"
1056//usage: IF_FEATURE_FIND_XDEV(
1057//usage: "\n -xdev Don't descend directories on other filesystems"
1058//usage: )
1059//usage: IF_FEATURE_FIND_MAXDEPTH(
1060//usage: "\n -maxdepth N Descend at most N levels. -maxdepth 0 applies"
1061//usage: "\n tests/actions to command line arguments only"
1062//usage: )
1063//usage: "\n -mindepth N Don't act on first N levels"
1064//usage: "\n -name PATTERN File name (w/o directory name) matches PATTERN"
1065//usage: "\n -iname PATTERN Case insensitive -name"
1066//usage: IF_FEATURE_FIND_PATH(
1067//usage: "\n -path PATTERN Path matches PATTERN"
1068//usage: )
1069//usage: IF_FEATURE_FIND_REGEX(
1070//usage: "\n -regex PATTERN Path matches regex PATTERN"
1071//usage: )
1072//usage: IF_FEATURE_FIND_TYPE(
1073//usage: "\n -type X File type is X (X is one of: f,d,l,b,c,...)"
1074//usage: )
1075//usage: IF_FEATURE_FIND_PERM(
1076//usage: "\n -perm NNN Permissions match any of (+NNN), all of (-NNN),"
1077//usage: "\n or exactly NNN"
1078//usage: )
1079//usage: IF_FEATURE_FIND_MTIME(
1080//usage: "\n -mtime DAYS Modified time is greater than (+N), less than (-N),"
1081//usage: "\n or exactly N days"
1082//usage: )
1083//usage: IF_FEATURE_FIND_MMIN(
1084//usage: "\n -mmin MINS Modified time is greater than (+N), less than (-N),"
1085//usage: "\n or exactly N minutes"
1086//usage: )
1087//usage: IF_FEATURE_FIND_NEWER(
1088//usage: "\n -newer FILE Modified time is more recent than FILE's"
1089//usage: )
1090//usage: IF_FEATURE_FIND_INUM(
1091//usage: "\n -inum N File has inode number N"
1092//usage: )
1093//usage: IF_FEATURE_FIND_USER(
1094//usage: "\n -user NAME File is owned by user NAME (numeric user ID allowed)"
1095//usage: )
1096//usage: IF_FEATURE_FIND_GROUP(
1097//usage: "\n -group NAME File belongs to group NAME (numeric group ID allowed)"
1098//usage: )
1099//usage: IF_FEATURE_FIND_DEPTH(
1100//usage: "\n -depth Process directory name after traversing it"
1101//usage: )
1102//usage: IF_FEATURE_FIND_SIZE(
1103//usage: "\n -size N[bck] File size is N (c:bytes,k:kbytes,b:512 bytes(def.))"
1104//usage: "\n +/-N: file size is bigger/smaller than N"
1105//usage: )
1106//usage: IF_FEATURE_FIND_LINKS(
1107//usage: "\n -links N Number of links is greater than (+N), less than (-N),"
1108//usage: "\n or exactly N"
1109//usage: )
1110//usage: "\n -print Print (default and assumed)"
1111//usage: IF_FEATURE_FIND_PRINT0(
1112//usage: "\n -print0 Delimit output with null characters rather than"
1113//usage: "\n newlines"
1114//usage: )
1115//usage: IF_FEATURE_FIND_CONTEXT(
1116//usage: "\n -context File has specified security context"
1117//usage: )
1118//usage: IF_FEATURE_FIND_EXEC(
1119//usage: "\n -exec CMD ARG ; Run CMD with all instances of {} replaced by the"
1120//usage: "\n matching files"
1121//usage: )
1122//usage: IF_FEATURE_FIND_PRUNE(
1123//usage: "\n -prune Stop traversing current subtree"
1124//usage: )
1125//usage: IF_FEATURE_FIND_DELETE(
1126//usage: "\n -delete Delete files, turns on -depth option"
1127//usage: )
1128//usage: IF_FEATURE_FIND_PAREN(
1129//usage: "\n (EXPR) Group an expression"
1130//usage: )
1131//usage:
1132//usage:#define find_example_usage
1133//usage: "$ find / -name passwd\n"
1134//usage: "/etc/passwd\n"
1047 1135
1048int find_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 1136int find_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
1049int find_main(int argc UNUSED_PARAM, char **argv) 1137int find_main(int argc UNUSED_PARAM, char **argv)
diff --git a/findutils/grep.c b/findutils/grep.c
index dd1a4efc4..ac290a911 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -14,13 +14,16 @@
14 * 2004,2006 (C) Vladimir Oleynik <dzo@simtreas.ru> - 14 * 2004,2006 (C) Vladimir Oleynik <dzo@simtreas.ru> -
15 * correction "-e pattern1 -e pattern2" logic and more optimizations. 15 * correction "-e pattern1 -e pattern2" logic and more optimizations.
16 * precompiled regex 16 * precompiled regex
17 */ 17 *
18/*
19 * (C) 2006 Jac Goudsmit added -o option 18 * (C) 2006 Jac Goudsmit added -o option
20 */ 19 */
21 20
21//applet:IF_GREP(APPLET(grep, _BB_DIR_BIN, _BB_SUID_DROP))
22//applet:IF_FEATURE_GREP_EGREP_ALIAS(APPLET_ODDNAME(egrep, grep, _BB_DIR_BIN, _BB_SUID_DROP, egrep))
23//applet:IF_FEATURE_GREP_FGREP_ALIAS(APPLET_ODDNAME(fgrep, grep, _BB_DIR_BIN, _BB_SUID_DROP, fgrep))
24
22//kbuild:lib-$(CONFIG_GREP) += grep.o 25//kbuild:lib-$(CONFIG_GREP) += grep.o
23//config: 26
24//config:config GREP 27//config:config GREP
25//config: bool "grep" 28//config: bool "grep"
26//config: default y 29//config: default y
@@ -57,17 +60,67 @@
57#include "libbb.h" 60#include "libbb.h"
58#include "xregex.h" 61#include "xregex.h"
59 62
63
60/* options */ 64/* options */
65//usage:#define grep_trivial_usage
66//usage: "[-HhnlLoqvsriw"
67//usage: "F"
68//usage: IF_FEATURE_GREP_EGREP_ALIAS("E")
69//usage: IF_EXTRA_COMPAT("z")
70//usage: "] [-m N] "
71//usage: IF_FEATURE_GREP_CONTEXT("[-A/B/C N] ")
72//usage: "PATTERN/-e PATTERN.../-f FILE [FILE]..."
73//usage:#define grep_full_usage "\n\n"
74//usage: "Search for PATTERN in FILEs (or stdin)\n"
75//usage: "\nOptions:"
76//usage: "\n -H Add 'filename:' prefix"
77//usage: "\n -h Do not add 'filename:' prefix"
78//usage: "\n -n Add 'line_no:' prefix"
79//usage: "\n -l Show only names of files that match"
80//usage: "\n -L Show only names of files that don't match"
81//usage: "\n -c Show only count of matching lines"
82//usage: "\n -o Show only the matching part of line"
83//usage: "\n -q Quiet. Return 0 if PATTERN is found, 1 otherwise"
84//usage: "\n -v Select non-matching lines"
85//usage: "\n -s Suppress open and read errors"
86//usage: "\n -r Recurse"
87//usage: "\n -i Ignore case"
88//usage: "\n -w Match whole words only"
89//usage: "\n -F PATTERN is a literal (not regexp)"
90//usage: IF_FEATURE_GREP_EGREP_ALIAS(
91//usage: "\n -E PATTERN is an extended regexp"
92//usage: )
93//usage: IF_EXTRA_COMPAT(
94//usage: "\n -z Input is NUL terminated"
95//usage: )
96//usage: "\n -m N Match up to N times per file"
97//usage: IF_FEATURE_GREP_CONTEXT(
98//usage: "\n -A N Print N lines of trailing context"
99//usage: "\n -B N Print N lines of leading context"
100//usage: "\n -C N Same as '-A N -B N'"
101//usage: )
102//usage: "\n -e PTRN Pattern to match"
103//usage: "\n -f FILE Read pattern from file"
104//usage:
105//usage:#define grep_example_usage
106//usage: "$ grep root /etc/passwd\n"
107//usage: "root:x:0:0:root:/root:/bin/bash\n"
108//usage: "$ grep ^[rR]oo. /etc/passwd\n"
109//usage: "root:x:0:0:root:/root:/bin/bash\n"
110//usage:
111//usage:#define egrep_trivial_usage NOUSAGE_STR
112//usage:#define egrep_full_usage ""
113//usage:#define fgrep_trivial_usage NOUSAGE_STR
114//usage:#define fgrep_full_usage ""
115
61#define OPTSTR_GREP \ 116#define OPTSTR_GREP \
62 "lnqvscFiHhe:f:Lorm:w" \ 117 "lnqvscFiHhe:f:Lorm:w" \
63 IF_FEATURE_GREP_CONTEXT("A:B:C:") \ 118 IF_FEATURE_GREP_CONTEXT("A:B:C:") \
64 IF_FEATURE_GREP_EGREP_ALIAS("E") \ 119 IF_FEATURE_GREP_EGREP_ALIAS("E") \
65 IF_EXTRA_COMPAT("z") \ 120 IF_EXTRA_COMPAT("z") \
66 "aI" 121 "aI"
67
68/* ignored: -a "assume all files to be text" */ 122/* ignored: -a "assume all files to be text" */
69/* ignored: -I "assume binary files have no matches" */ 123/* ignored: -I "assume binary files have no matches" */
70
71enum { 124enum {
72 OPTBIT_l, /* list matched file names only */ 125 OPTBIT_l, /* list matched file names only */
73 OPTBIT_n, /* print line# */ 126 OPTBIT_n, /* print line# */
diff --git a/findutils/xargs.c b/findutils/xargs.c
index 8caaff91c..46a62cbf1 100644
--- a/findutils/xargs.c
+++ b/findutils/xargs.c
@@ -1,7 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * Mini xargs implementation for busybox 3 * Mini xargs implementation for busybox
4 * Options are supported: "-prtx -n max_arg -s max_chars -e[ouf_str]"
5 * 4 *
6 * (C) 2002,2003 by Vladimir Oleynik <dzo@simtreas.ru> 5 * (C) 2002,2003 by Vladimir Oleynik <dzo@simtreas.ru>
7 * 6 *
@@ -14,9 +13,10 @@
14 * 13 *
15 * xargs is described in the Single Unix Specification v3 at 14 * xargs is described in the Single Unix Specification v3 at
16 * http://www.opengroup.org/onlinepubs/007904975/utilities/xargs.html 15 * http://www.opengroup.org/onlinepubs/007904975/utilities/xargs.html
17 *
18 */ 16 */
19 17
18//applet:IF_XARGS(APPLET_NOEXEC(xargs, xargs, _BB_DIR_USR_BIN, _BB_SUID_DROP, xargs))
19
20//kbuild:lib-$(CONFIG_XARGS) += xargs.o 20//kbuild:lib-$(CONFIG_XARGS) += xargs.o
21 21
22//config:config XARGS 22//config:config XARGS
@@ -351,6 +351,29 @@ static int xargs_ask_confirmation(void)
351# define xargs_ask_confirmation() 1 351# define xargs_ask_confirmation() 1
352#endif 352#endif
353 353
354//usage:#define xargs_trivial_usage
355//usage: "[OPTIONS] [PROG ARGS]"
356//usage:#define xargs_full_usage "\n\n"
357//usage: "Run PROG on every item given by stdin\n"
358//usage: "\nOptions:"
359//usage: IF_FEATURE_XARGS_SUPPORT_CONFIRMATION(
360//usage: "\n -p Ask user whether to run each command"
361//usage: )
362//usage: "\n -r Don't run command if input is empty"
363//usage: IF_FEATURE_XARGS_SUPPORT_ZERO_TERM(
364//usage: "\n -0 Input is separated by NUL characters"
365//usage: )
366//usage: "\n -t Print the command on stderr before execution"
367//usage: "\n -e[STR] STR stops input processing"
368//usage: "\n -n N Pass no more than N args to PROG"
369//usage: "\n -s N Pass command line of no more than N bytes"
370//usage: IF_FEATURE_XARGS_SUPPORT_TERMOPT(
371//usage: "\n -x Exit if size is exceeded"
372//usage: )
373//usage:#define xargs_example_usage
374//usage: "$ ls | xargs gzip\n"
375//usage: "$ find . -name '*.c' -print | xargs rm\n"
376
354/* Correct regardless of combination of CONFIG_xxx */ 377/* Correct regardless of combination of CONFIG_xxx */
355enum { 378enum {
356 OPTBIT_VERBOSE = 0, 379 OPTBIT_VERBOSE = 0,