From: Ben Gras Date: Sat, 3 Jul 2010 22:18:11 +0000 (+0000) Subject: ash: make test/expr support 'file1 -ot file2' X-Git-Tag: v3.1.8~290 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/doc/syslog.3.html?a=commitdiff_plain;h=01fcee7d71d1c7a15f90c672a0191d95d83c02fe;p=minix.git ash: make test/expr support 'file1 -ot file2' --- diff --git a/commands/ash/bltin/binary_op b/commands/ash/bltin/binary_op index 9dd732b63..74381107b 100755 --- a/commands/ash/bltin/binary_op +++ b/commands/ash/bltin/binary_op @@ -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 diff --git a/commands/ash/bltin/expr.c b/commands/ash/bltin/expr.c index 63e2844f7..88d8c05cc 100644 --- a/commands/ash/bltin/expr.c +++ b/commands/ash/bltin/expr.c @@ -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;