add aliases == and [[ for = and [ to support more bash scripts
authorMike Frysinger <vapier@gentoo.org>
Thu, 14 Apr 2005 02:49:22 +0000 (02:49 -0000)
committerMike Frysinger <vapier@gentoo.org>
Thu, 14 Apr 2005 02:49:22 +0000 (02:49 -0000)
coreutils/test.c
include/applets.h

index 8fa6d166fb706509aacb3904a19ff4f9c955c176..cec3c471d1ba4fc0fcf82a74f448e4a664b2de18 100644 (file)
@@ -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:
index 1257032166ac65d90b70b24f28a5d5e370a911c2..90a081550057335663b4a579e6fb25e903eef27b 100644 (file)
@@ -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)