From: arisawa <arisawa@ar.aichi-u.ac.jp>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] bug? test f -older t
Date: Tue, 1 Oct 2013 20:44:24 +0900 [thread overview]
Message-ID: <A2EFA167-AA11-43A5-A056-AE9E8F5F6D6C@ar.aichi-u.ac.jp> (raw)
In-Reply-To: <7963B664-4127-47A3-B8CF-88FA70C52AA6@ar.aichi-u.ac.jp>
I have forgotten that I took up this bug in Jun this year.
Already fixed in distribution?
On 2013/10/01, at 20:34, arisawa <arisawa@ar.aichi-u.ac.jp> wrote:
> 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;
> }
>
>
>
>
next prev parent reply other threads:[~2013-10-01 11:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-01 11:34 arisawa
2013-10-01 11:44 ` arisawa [this message]
2013-10-01 11:53 ` erik quanstrom
2013-10-01 13:10 ` arisawa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=A2EFA167-AA11-43A5-A056-AE9E8F5F6D6C@ar.aichi-u.ac.jp \
--to=arisawa@ar.aichi-u.ac.jp \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).