ash: make test/expr support 'file1 -ot file2'
This commit is contained in:
parent
4d3c887d6b
commit
01fcee7d71
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue