summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger2005-04-14 02:49:22 +0000
committerMike Frysinger2005-04-14 02:49:22 +0000
commit75ac42b1aea14abbd8633003a6c56fa28c27a6c9 (patch)
treedcb9edcbd4e973f31208ed9aaec7d1c1def5d18e
parentc089ccdb441cf1493e974fa2ed4f9ac22c5637c7 (diff)
downloadbusybox-75ac42b1aea14abbd8633003a6c56fa28c27a6c9.zip
busybox-75ac42b1aea14abbd8633003a6c56fa28c27a6c9.tar.gz
add aliases == and [[ for = and [ to support more bash scripts
-rw-r--r--coreutils/test.c8
-rw-r--r--include/applets.h1
2 files changed, 8 insertions, 1 deletions
diff --git a/coreutils/test.c b/coreutils/test.c
index 8fa6d16..cec3c47 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -51,7 +51,7 @@
unary-operator ::= "-r"|"-w"|"-x"|"-f"|"-d"|"-c"|"-b"|"-p"|
"-u"|"-g"|"-k"|"-s"|"-t"|"-z"|"-n"|"-o"|"-O"|"-G"|"-L"|"-S";
- binary-operator ::= "="|"!="|"-eq"|"-ne"|"-ge"|"-gt"|"-le"|"-lt"|
+ binary-operator ::= "="|"=="|"!="|"-eq"|"-ne"|"-ge"|"-gt"|"-le"|"-lt"|
"-nt"|"-ot"|"-ef";
operand ::= <any legal UNIX file name>
*/
@@ -135,6 +135,7 @@ static const struct t_op {
"-L", FILSYM, UNOP}, {
"-S", FILSOCK, UNOP}, {
"=", STREQ, BINOP}, {
+ "==", STREQ, BINOP}, {
"!=", STRNE, BINOP}, {
"<", STRLT, BINOP}, {
">", STRGT, BINOP}, {
@@ -191,6 +192,11 @@ extern int test_main(int argc, char **argv)
bb_error_msg_and_die("missing ]");
argv[argc] = NULL;
}
+ if (strcmp(bb_applet_name, "[[") == 0) {
+ if (strcmp(argv[--argc], "]]"))
+ bb_error_msg_and_die("missing ]]");
+ argv[argc] = NULL;
+ }
/* Implement special cases from POSIX.2, section 4.62.4 */
switch (argc) {
case 1:
diff --git a/include/applets.h b/include/applets.h
index 1257032..90a0815 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -50,6 +50,7 @@
#ifdef CONFIG_TEST
APPLET_NOUSAGE("[", test_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
+ APPLET_NOUSAGE("[[", test_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
#endif
#ifdef CONFIG_ADDGROUP
APPLET(addgroup, addgroup_main, _BB_DIR_BIN, _BB_SUID_NEVER)