]> Zhao Yanbai Git Server - minix.git/commitdiff
ash: make test/expr support 'file1 -ot file2'
authorBen Gras <ben@minix3.org>
Sat, 3 Jul 2010 22:18:11 +0000 (22:18 +0000)
committerBen Gras <ben@minix3.org>
Sat, 3 Jul 2010 22:18:11 +0000 (22:18 +0000)
commands/ash/bltin/binary_op
commands/ash/bltin/expr.c

index 9dd732b638c3684d7a16d59f2062894d0ed7fcb3..74381107b04d52930bc0a2551c58b461c2f70db1 100755 (executable)
@@ -11,6 +11,7 @@ AND2   &      2
 STREQ   =      4    OP_STRING
 STRNE   !=     4    OP_STRING
 NEWER   -newer 4    OP_STRING
+OLDER   -ot    4    OP_STRING
 EQ      -eq    4    OP_INT
 NE      -ne    4    OP_INT
 GT      -gt    4    OP_INT
index 63e2844f7666596d0f60c1ea589ea7d77693e72f..88d8c05ccdfba35a69fafefa2b8a41169df6c26a 100644 (file)
@@ -347,13 +347,18 @@ filebit:
            sp->u.num = fs->rcode >= 0? fs->stat.st_size : 0L;
            sp->type = INTEGER;
            break;
+      case OLDER:
       case NEWER:
            if (stat(sp->u.string, &st1) != 0) {
                  sp->u.num = 0;
            } else if (stat((sp + 1)->u.string, &st2) != 0) {
                  sp->u.num = 1;
            } else {
-                 sp->u.num = st1.st_mtime >= st2.st_mtime;
+               int isnewer = st1.st_mtime >= st2.st_mtime;
+               if(op == NEWER)
+                 sp->u.num = isnewer;
+               else
+                 sp->u.num = !isnewer;
            }
            sp->type = INTEGER;
            break;