From mboxrd@z Thu Jan 1 00:00:00 1970 From: arisawa Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <7963B664-4127-47A3-B8CF-88FA70C52AA6@ar.aichi-u.ac.jp> Date: Tue, 1 Oct 2013 20:34:20 +0900 To: 9fans@9fans.net Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Subject: [9fans] bug? test f -older t Topicbox-Message-UUID: 82ca1832-ead8-11e9-9d60-3106f5b1d025 Hello, Am I missing something? It seems logic is inverted to me. Kenji Arisawa maia% ls -l ... --rw-rw-r-- M 323 arisawa arisawa 0 Sep 29 06:29 x --rw-rw-r-- M 323 arisawa arisawa 14 Sep 28 17:50 z maia% mtime x 1380403777 x maia% if(test z -older 1380403777) echo older maia% if(! test z -older 1380403777) echo older older maia% man test(1) f -older t True if file f is older than (modified before) time t. If t is a integer followed by the letters y(years), M(months), d(days), h(hours), m(minutes), or s(seconds), it represents current time minus the specified time. If there is no letter, it represents seconds since epoch. You can also concatenate mixed units. For example, 3d12h means three days and twelve hours ago. the source code /sys/src/cmd/test.c int isolder(char *pin, char *f) { int r; ulong n, m; char *p = pin; Dir *dir; dir = dirstat(f); if (dir == nil) return 0; /* parse time */ n = 0; while(*p){ m = strtoul(p, &p, 0); switch(*p){ case 0: n = m; break; case 'y': m *= 12; /* fall through */ case 'M': m *= 30; /* fall through */ case 'd': m *= 24; /* fall through */ case 'h': m *= 60; /* fall through */ case 'm': m *= 60; /* fall through */ case 's': n += m; p++; break; default: synbad("bad time syntax, ", pin); } } r = dir->mtime + n < time(0); free(dir); return r; }