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-4f731ce30ec2a9f5e9b231b47aa68f32b75feb35.tar.gz
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 @@
* diff -u /tmp/std_find /tmp/bb_find && echo Identical
*/
+//applet:IF_FIND(APPLET_NOEXEC(find, find, _BB_DIR_USR_BIN, _BB_SUID_DROP, find))
+
//kbuild:lib-$(CONFIG_FIND) += find.o
-//config:
+
//config:config FIND
//config: bool "find"
//config: default y
@@ -1044,6 +1046,92 @@ static action*** parse_params(char **argv)
#undef ALLOC_ACTION
}
+//usage:#define find_trivial_usage
+//usage: "[PATH]... [EXPRESSION]"
+//usage:#define find_full_usage "\n\n"
+//usage: "Search for files. The default PATH is the current directory,\n"
+//usage: "default EXPRESSION is '-print'\n"
+//usage: "\nEXPRESSION may consist of:"
+//usage: "\n -follow Follow symlinks"
+//usage: IF_FEATURE_FIND_XDEV(
+//usage: "\n -xdev Don't descend directories on other filesystems"
+//usage: )
+//usage: IF_FEATURE_FIND_MAXDEPTH(
+//usage: "\n -maxdepth N Descend at most N levels. -maxdepth 0 applies"
+//usage: "\n tests/actions to command line arguments only"
+//usage: )
+//usage: "\n -mindepth N Don't act on first N levels"
+//usage: "\n -name PATTERN File name (w/o directory name) matches PATTERN"
+//usage: "\n -iname PATTERN Case insensitive -name"
+//usage: IF_FEATURE_FIND_PATH(
+//usage: "\n -path PATTERN Path matches PATTERN"
+//usage: )
+//usage: IF_FEATURE_FIND_REGEX(
+//usage: "\n -regex PATTERN Path matches regex PATTERN"
+//usage: )
+//usage: IF_FEATURE_FIND_TYPE(
+//usage: "\n -type X File type is X (X is one of: f,d,l,b,c,...)"
+//usage: )
+//usage: IF_FEATURE_FIND_PERM(
+//usage: "\n -perm NNN Permissions match any of (+NNN), all of (-NNN),"
+//usage: "\n or exactly NNN"
+//usage: )
+//usage: IF_FEATURE_FIND_MTIME(
+//usage: "\n -mtime DAYS Modified time is greater than (+N), less than (-N),"
+//usage: "\n or exactly N days"
+//usage: )
+//usage: IF_FEATURE_FIND_MMIN(
+//usage: "\n -mmin MINS Modified time is greater than (+N), less than (-N),"
+//usage: "\n or exactly N minutes"
+//usage: )
+//usage: IF_FEATURE_FIND_NEWER(
+//usage: "\n -newer FILE Modified time is more recent than FILE's"
+//usage: )
+//usage: IF_FEATURE_FIND_INUM(
+//usage: "\n -inum N File has inode number N"
+//usage: )
+//usage: IF_FEATURE_FIND_USER(
+//usage: "\n -user NAME File is owned by user NAME (numeric user ID allowed)"
+//usage: )
+//usage: IF_FEATURE_FIND_GROUP(
+//usage: "\n -group NAME File belongs to group NAME (numeric group ID allowed)"
+//usage: )
+//usage: IF_FEATURE_FIND_DEPTH(
+//usage: "\n -depth Process directory name after traversing it"
+//usage: )
+//usage: IF_FEATURE_FIND_SIZE(
+//usage: "\n -size N[bck] File size is N (c:bytes,k:kbytes,b:512 bytes(def.))"
+//usage: "\n +/-N: file size is bigger/smaller than N"
+//usage: )
+//usage: IF_FEATURE_FIND_LINKS(
+//usage: "\n -links N Number of links is greater than (+N), less than (-N),"
+//usage: "\n or exactly N"
+//usage: )
+//usage: "\n -print Print (default and assumed)"
+//usage: IF_FEATURE_FIND_PRINT0(
+//usage: "\n -print0 Delimit output with null characters rather than"
+//usage: "\n newlines"
+//usage: )
+//usage: IF_FEATURE_FIND_CONTEXT(
+//usage: "\n -context File has specified security context"
+//usage: )
+//usage: IF_FEATURE_FIND_EXEC(
+//usage: "\n -exec CMD ARG ; Run CMD with all instances of {} replaced by the"
+//usage: "\n matching files"
+//usage: )
+//usage: IF_FEATURE_FIND_PRUNE(
+//usage: "\n -prune Stop traversing current subtree"
+//usage: )
+//usage: IF_FEATURE_FIND_DELETE(
+//usage: "\n -delete Delete files, turns on -depth option"
+//usage: )
+//usage: IF_FEATURE_FIND_PAREN(
+//usage: "\n (EXPR) Group an expression"
+//usage: )
+//usage:
+//usage:#define find_example_usage
+//usage: "$ find / -name passwd\n"
+//usage: "/etc/passwd\n"
int find_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int 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 @@
* 2004,2006 (C) Vladimir Oleynik <dzo@simtreas.ru> -
* correction "-e pattern1 -e pattern2" logic and more optimizations.
* precompiled regex
- */
-/*
+ *
* (C) 2006 Jac Goudsmit added -o option
*/
+//applet:IF_GREP(APPLET(grep, _BB_DIR_BIN, _BB_SUID_DROP))
+//applet:IF_FEATURE_GREP_EGREP_ALIAS(APPLET_ODDNAME(egrep, grep, _BB_DIR_BIN, _BB_SUID_DROP, egrep))
+//applet:IF_FEATURE_GREP_FGREP_ALIAS(APPLET_ODDNAME(fgrep, grep, _BB_DIR_BIN, _BB_SUID_DROP, fgrep))
+
//kbuild:lib-$(CONFIG_GREP) += grep.o
-//config:
+
//config:config GREP
//config: bool "grep"
//config: default y
@@ -57,17 +60,67 @@
#include "libbb.h"
#include "xregex.h"
+
/* options */
+//usage:#define grep_trivial_usage
+//usage: "[-HhnlLoqvsriw"
+//usage: "F"
+//usage: IF_FEATURE_GREP_EGREP_ALIAS("E")
+//usage: IF_EXTRA_COMPAT("z")
+//usage: "] [-m N] "
+//usage: IF_FEATURE_GREP_CONTEXT("[-A/B/C N] ")
+//usage: "PATTERN/-e PATTERN.../-f FILE [FILE]..."
+//usage:#define grep_full_usage "\n\n"
+//usage: "Search for PATTERN in FILEs (or stdin)\n"
+//usage: "\nOptions:"
+//usage: "\n -H Add 'filename:' prefix"
+//usage: "\n -h Do not add 'filename:' prefix"
+//usage: "\n -n Add 'line_no:' prefix"
+//usage: "\n -l Show only names of files that match"
+//usage: "\n -L Show only names of files that don't match"
+//usage: "\n -c Show only count of matching lines"
+//usage: "\n -o Show only the matching part of line"
+//usage: "\n -q Quiet. Return 0 if PATTERN is found, 1 otherwise"
+//usage: "\n -v Select non-matching lines"
+//usage: "\n -s Suppress open and read errors"
+//usage: "\n -r Recurse"
+//usage: "\n -i Ignore case"
+//usage: "\n -w Match whole words only"
+//usage: "\n -F PATTERN is a literal (not regexp)"
+//usage: IF_FEATURE_GREP_EGREP_ALIAS(
+//usage: "\n -E PATTERN is an extended regexp"
+//usage: )
+//usage: IF_EXTRA_COMPAT(
+//usage: "\n -z Input is NUL terminated"
+//usage: )
+//usage: "\n -m N Match up to N times per file"
+//usage: IF_FEATURE_GREP_CONTEXT(
+//usage: "\n -A N Print N lines of trailing context"
+//usage: "\n -B N Print N lines of leading context"
+//usage: "\n -C N Same as '-A N -B N'"
+//usage: )
+//usage: "\n -e PTRN Pattern to match"
+//usage: "\n -f FILE Read pattern from file"
+//usage:
+//usage:#define grep_example_usage
+//usage: "$ grep root /etc/passwd\n"
+//usage: "root:x:0:0:root:/root:/bin/bash\n"
+//usage: "$ grep ^[rR]oo. /etc/passwd\n"
+//usage: "root:x:0:0:root:/root:/bin/bash\n"
+//usage:
+//usage:#define egrep_trivial_usage NOUSAGE_STR
+//usage:#define egrep_full_usage ""
+//usage:#define fgrep_trivial_usage NOUSAGE_STR
+//usage:#define fgrep_full_usage ""
+
#define OPTSTR_GREP \
"lnqvscFiHhe:f:Lorm:w" \
IF_FEATURE_GREP_CONTEXT("A:B:C:") \
IF_FEATURE_GREP_EGREP_ALIAS("E") \
IF_EXTRA_COMPAT("z") \
"aI"
-
/* ignored: -a "assume all files to be text" */
/* ignored: -I "assume binary files have no matches" */
-
enum {
OPTBIT_l, /* list matched file names only */
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 @@
/* vi: set sw=4 ts=4: */
/*
* Mini xargs implementation for busybox
- * Options are supported: "-prtx -n max_arg -s max_chars -e[ouf_str]"
*
* (C) 2002,2003 by Vladimir Oleynik <dzo@simtreas.ru>
*
@@ -14,9 +13,10 @@
*
* xargs is described in the Single Unix Specification v3 at
* http://www.opengroup.org/onlinepubs/007904975/utilities/xargs.html
- *
*/
+//applet:IF_XARGS(APPLET_NOEXEC(xargs, xargs, _BB_DIR_USR_BIN, _BB_SUID_DROP, xargs))
+
//kbuild:lib-$(CONFIG_XARGS) += xargs.o
//config:config XARGS
@@ -351,6 +351,29 @@ static int xargs_ask_confirmation(void)
# define xargs_ask_confirmation() 1
#endif
+//usage:#define xargs_trivial_usage
+//usage: "[OPTIONS] [PROG ARGS]"
+//usage:#define xargs_full_usage "\n\n"
+//usage: "Run PROG on every item given by stdin\n"
+//usage: "\nOptions:"
+//usage: IF_FEATURE_XARGS_SUPPORT_CONFIRMATION(
+//usage: "\n -p Ask user whether to run each command"
+//usage: )
+//usage: "\n -r Don't run command if input is empty"
+//usage: IF_FEATURE_XARGS_SUPPORT_ZERO_TERM(
+//usage: "\n -0 Input is separated by NUL characters"
+//usage: )
+//usage: "\n -t Print the command on stderr before execution"
+//usage: "\n -e[STR] STR stops input processing"
+//usage: "\n -n N Pass no more than N args to PROG"
+//usage: "\n -s N Pass command line of no more than N bytes"
+//usage: IF_FEATURE_XARGS_SUPPORT_TERMOPT(
+//usage: "\n -x Exit if size is exceeded"
+//usage: )
+//usage:#define xargs_example_usage
+//usage: "$ ls | xargs gzip\n"
+//usage: "$ find . -name '*.c' -print | xargs rm\n"
+
/* Correct regardless of combination of CONFIG_xxx */
enum {
OPTBIT_VERBOSE = 0,