diff options
| author | Eric Andersen <andersen@codepoet.org> | 2000-09-05 17:37:48 +0000 |
|---|---|---|
| committer | Eric Andersen <andersen@codepoet.org> | 2000-09-05 17:37:48 +0000 |
| commit | 1b355ebba68bdd567dd3961a18291dfd9532c2e8 (patch) | |
| tree | c4c1cb4ed9cc025e05640e19c0b0a3f86080563a /applets | |
| parent | 43c8c38bbfe3d25e21f37d899184de52c6dc9c17 (diff) | |
| download | busybox-w32-1b355ebba68bdd567dd3961a18291dfd9532c2e8.tar.gz busybox-w32-1b355ebba68bdd567dd3961a18291dfd9532c2e8.tar.bz2 busybox-w32-1b355ebba68bdd567dd3961a18291dfd9532c2e8.zip | |
Added expr, from Edward Betts <edward@debian.org>, with some fixups
and docs added by me.
-Erik
Diffstat (limited to 'applets')
| -rw-r--r-- | applets/busybox.c | 3 | ||||
| -rwxr-xr-x | applets/busybox.sh | 2 | ||||
| -rw-r--r-- | applets/usage.c | 38 |
3 files changed, 42 insertions, 1 deletions
diff --git a/applets/busybox.c b/applets/busybox.c index 0ffa94e09..a7c5d37a0 100644 --- a/applets/busybox.c +++ b/applets/busybox.c | |||
| @@ -76,6 +76,9 @@ const struct BB_applet applets[] = { | |||
| 76 | #ifdef BB_ECHO | 76 | #ifdef BB_ECHO |
| 77 | {"echo", echo_main, _BB_DIR_BIN, echo_usage}, | 77 | {"echo", echo_main, _BB_DIR_BIN, echo_usage}, |
| 78 | #endif | 78 | #endif |
| 79 | #ifdef BB_EXPR | ||
| 80 | {"expr", expr_main, _BB_DIR_USR_BIN, expr_usage}, | ||
| 81 | #endif | ||
| 79 | #ifdef BB_TRUE_FALSE | 82 | #ifdef BB_TRUE_FALSE |
| 80 | {"false", false_main, _BB_DIR_BIN, false_usage}, | 83 | {"false", false_main, _BB_DIR_BIN, false_usage}, |
| 81 | #endif | 84 | #endif |
diff --git a/applets/busybox.sh b/applets/busybox.sh index 5dd6e1c3d..2b4521065 100755 --- a/applets/busybox.sh +++ b/applets/busybox.sh | |||
| @@ -5,6 +5,6 @@ | |||
| 5 | ls -1 ` \ | 5 | ls -1 ` \ |
| 6 | gcc -E -dM busybox.def.h | \ | 6 | gcc -E -dM busybox.def.h | \ |
| 7 | sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \ | 7 | sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \ |
| 8 | | tr [:upper:] [:lower:] | sort | 8 | | tr '[:upper:]' '[:lower:]' | sort |
| 9 | ` 2>/dev/null | sed -e 's/\.c$/\.o/g' | 9 | ` 2>/dev/null | sed -e 's/\.c$/\.o/g' |
| 10 | 10 | ||
diff --git a/applets/usage.c b/applets/usage.c index 91064f52c..05913f3e3 100644 --- a/applets/usage.c +++ b/applets/usage.c | |||
| @@ -250,6 +250,44 @@ const char echo_usage[] = | |||
| 250 | ; | 250 | ; |
| 251 | #endif | 251 | #endif |
| 252 | 252 | ||
| 253 | #if defined BB_EXPR | ||
| 254 | const char expr_usage[] = | ||
| 255 | "expr EXPRESSION\n" | ||
| 256 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
| 257 | "\nPrints the value of EXPRESSION to standard output.\n\n" | ||
| 258 | "EXPRESSION may be:\n" | ||
| 259 | "ARG1 | ARG2 ARG1 if it is neither null nor 0, otherwise ARG2\n" | ||
| 260 | "ARG1 & ARG2 ARG1 if neither argument is null or 0, otherwise 0\n" | ||
| 261 | "ARG1 < ARG2 ARG1 is less than ARG2\n" | ||
| 262 | "ARG1 <= ARG2 ARG1 is less than or equal to ARG2\n" | ||
| 263 | "ARG1 = ARG2 ARG1 is equal to ARG2\n" | ||
| 264 | "ARG1 != ARG2 ARG1 is unequal to ARG2\n" | ||
| 265 | "ARG1 >= ARG2 ARG1 is greater than or equal to ARG2\n" | ||
| 266 | "ARG1 > ARG2 ARG1 is greater than ARG2\n" | ||
| 267 | "ARG1 + ARG2 arithmetic sum of ARG1 and ARG2\n" | ||
| 268 | "ARG1 - ARG2 arithmetic difference of ARG1 and ARG2\n" | ||
| 269 | "ARG1 * ARG2 arithmetic product of ARG1 and ARG2\n" | ||
| 270 | "ARG1 / ARG2 arithmetic quotient of ARG1 divided by ARG2\n" | ||
| 271 | "ARG1 % ARG2 arithmetic remainder of ARG1 divided by ARG2\n" | ||
| 272 | "STRING : REGEXP anchored pattern match of REGEXP in STRING\n" | ||
| 273 | "match STRING REGEXP same as STRING : REGEXP\n" | ||
| 274 | "substr STRING POS LENGTH substring of STRING, POS counted from 1\n" | ||
| 275 | "index STRING CHARS index in STRING where any CHARS is found, or 0\n" | ||
| 276 | "length STRING length of STRING\n" | ||
| 277 | "quote TOKEN interpret TOKEN as a string, even if it is a \n" | ||
| 278 | " keyword like `match' or an operator like `/'\n" | ||
| 279 | "( EXPRESSION ) value of EXPRESSION\n\n" | ||
| 280 | "Beware that many operators need to be escaped or quoted for shells.\n" | ||
| 281 | "Comparisons are arithmetic if both ARGs are numbers, else\n" | ||
| 282 | "lexicographical. Pattern matches return the string matched between \n" | ||
| 283 | "\\( and \\) or null; if \\( and \\) are not used, they return the number \n" | ||
| 284 | "of characters matched or 0.\n" | ||
| 285 | |||
| 286 | #endif | ||
| 287 | ; | ||
| 288 | #endif | ||
| 289 | |||
| 290 | |||
| 253 | #if defined BB_TRUE_FALSE | 291 | #if defined BB_TRUE_FALSE |
| 254 | const char false_usage[] = | 292 | const char false_usage[] = |
| 255 | "false\n" | 293 | "false\n" |
