summaryrefslogtreecommitdiff
path: root/applets
diff options
context:
space:
mode:
authorEric Andersen2000-09-05 17:37:48 +0000
committerEric Andersen2000-09-05 17:37:48 +0000
commit1b355ebba68bdd567dd3961a18291dfd9532c2e8 (patch)
treec4c1cb4ed9cc025e05640e19c0b0a3f86080563a /applets
parent43c8c38bbfe3d25e21f37d899184de52c6dc9c17 (diff)
downloadbusybox-1b355ebba68bdd567dd3961a18291dfd9532c2e8.zip
busybox-1b355ebba68bdd567dd3961a18291dfd9532c2e8.tar.gz
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.c3
-rwxr-xr-xapplets/busybox.sh2
-rw-r--r--applets/usage.c38
3 files changed, 42 insertions, 1 deletions
diff --git a/applets/busybox.c b/applets/busybox.c
index 0ffa94e..a7c5d37 100644
--- a/applets/busybox.c
+++ b/applets/busybox.c
@@ -76,6 +76,9 @@ const struct BB_applet applets[] = {
#ifdef BB_ECHO
{"echo", echo_main, _BB_DIR_BIN, echo_usage},
#endif
+#ifdef BB_EXPR
+ {"expr", expr_main, _BB_DIR_USR_BIN, expr_usage},
+#endif
#ifdef BB_TRUE_FALSE
{"false", false_main, _BB_DIR_BIN, false_usage},
#endif
diff --git a/applets/busybox.sh b/applets/busybox.sh
index 5dd6e1c..2b45210 100755
--- a/applets/busybox.sh
+++ b/applets/busybox.sh
@@ -5,6 +5,6 @@
ls -1 ` \
gcc -E -dM busybox.def.h | \
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
- | tr [:upper:] [:lower:] | sort
+ | tr '[:upper:]' '[:lower:]' | sort
` 2>/dev/null | sed -e 's/\.c$/\.o/g'
diff --git a/applets/usage.c b/applets/usage.c
index 91064f5..05913f3 100644
--- a/applets/usage.c
+++ b/applets/usage.c
@@ -250,6 +250,44 @@ const char echo_usage[] =
;
#endif
+#if defined BB_EXPR
+const char expr_usage[] =
+ "expr EXPRESSION\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrints the value of EXPRESSION to standard output.\n\n"
+ "EXPRESSION may be:\n"
+ "ARG1 | ARG2 ARG1 if it is neither null nor 0, otherwise ARG2\n"
+ "ARG1 & ARG2 ARG1 if neither argument is null or 0, otherwise 0\n"
+ "ARG1 < ARG2 ARG1 is less than ARG2\n"
+ "ARG1 <= ARG2 ARG1 is less than or equal to ARG2\n"
+ "ARG1 = ARG2 ARG1 is equal to ARG2\n"
+ "ARG1 != ARG2 ARG1 is unequal to ARG2\n"
+ "ARG1 >= ARG2 ARG1 is greater than or equal to ARG2\n"
+ "ARG1 > ARG2 ARG1 is greater than ARG2\n"
+ "ARG1 + ARG2 arithmetic sum of ARG1 and ARG2\n"
+ "ARG1 - ARG2 arithmetic difference of ARG1 and ARG2\n"
+ "ARG1 * ARG2 arithmetic product of ARG1 and ARG2\n"
+ "ARG1 / ARG2 arithmetic quotient of ARG1 divided by ARG2\n"
+ "ARG1 % ARG2 arithmetic remainder of ARG1 divided by ARG2\n"
+ "STRING : REGEXP anchored pattern match of REGEXP in STRING\n"
+ "match STRING REGEXP same as STRING : REGEXP\n"
+ "substr STRING POS LENGTH substring of STRING, POS counted from 1\n"
+ "index STRING CHARS index in STRING where any CHARS is found, or 0\n"
+ "length STRING length of STRING\n"
+ "quote TOKEN interpret TOKEN as a string, even if it is a \n"
+ " keyword like `match' or an operator like `/'\n"
+ "( EXPRESSION ) value of EXPRESSION\n\n"
+ "Beware that many operators need to be escaped or quoted for shells.\n"
+ "Comparisons are arithmetic if both ARGs are numbers, else\n"
+ "lexicographical. Pattern matches return the string matched between \n"
+ "\\( and \\) or null; if \\( and \\) are not used, they return the number \n"
+ "of characters matched or 0.\n"
+
+#endif
+ ;
+#endif
+
+
#if defined BB_TRUE_FALSE
const char false_usage[] =
"false\n"