diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1999-07-14 13:37:25 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1999-07-14 13:37:25 +0000 |
commit | b1e130a5dfda09ae8a7ebe9ef8b2b31a7ea0072d (patch) | |
tree | 50a19d3ae6026d39eef62c7403512f3944b5de49 /bin/ksh/c_test.c | |
parent | 9f95e00383dedac23c9855efa31e7556dd79de4c (diff) |
pdksh-5.2.14
Diffstat (limited to 'bin/ksh/c_test.c')
-rw-r--r-- | bin/ksh/c_test.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/bin/ksh/c_test.c b/bin/ksh/c_test.c index 8ea1b4c94b7..915d709f2c1 100644 --- a/bin/ksh/c_test.c +++ b/bin/ksh/c_test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_test.c,v 1.6 1999/06/15 01:18:33 millert Exp $ */ +/* $OpenBSD: c_test.c,v 1.7 1999/07/14 13:37:23 millert Exp $ */ /* * test(1); version 7-like -- author Erik Baalbergen @@ -388,11 +388,25 @@ test_eval(te, op, opnd1, opnd2, do_eval) } } case TO_FILNT: /* -nt */ - return stat (opnd1, &b1) == 0 && stat (opnd2, &b2) == 0 - && b1.st_mtime > b2.st_mtime; + { + int s2; + /* ksh88/ksh93 succeed if file2 can't be stated + * (subtly different from `does not exist'). + */ + return stat(opnd1, &b1) == 0 + && (((s2 = stat(opnd2, &b2)) == 0 + && b1.st_mtime > b2.st_mtime) || s2 < 0); + } case TO_FILOT: /* -ot */ - return stat (opnd1, &b1) == 0 && stat (opnd2, &b2) == 0 - && b1.st_mtime < b2.st_mtime; + { + int s1; + /* ksh88/ksh93 succeed if file1 can't be stated + * (subtly different from `does not exist'). + */ + return stat(opnd2, &b2) == 0 + && (((s1 = stat(opnd1, &b1)) == 0 + && b1.st_mtime < b2.st_mtime) || s1 < 0); + } case TO_FILEQ: /* -ef */ return stat (opnd1, &b1) == 0 && stat (opnd2, &b2) == 0 && b1.st_dev == b2.st_dev |