From cfa8d336db1b63a761be1d11251ad5d06b702d81 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 7 Feb 2022 15:41:52 -0600 Subject: [PATCH] Fix -newerXY and add test. --- tests/find.test | 7 ++++++- toys/posix/find.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/find.test b/tests/find.test index 74a452aa..344489dc 100755 --- a/tests/find.test +++ b/tests/find.test @@ -149,5 +149,10 @@ testing 'quit' 'find dir perm -print -quit' 'dir\n' '' '' ln dir/file perm/hardlink testing 'samefile' 'find . -samefile dir/file | sort' \ './dir/file\n./perm/hardlink\n' '' '' - rm -rf dir broken perm irrelevant + +mkdir dir +touch -d @12345 dir/one +touch -d @12346 dir/two +testing 'newerat' 'find dir -type f -newerat @12345' 'dir/two\n' '' '' +rm -rf dir diff --git a/toys/posix/find.c b/toys/posix/find.c index 6a792544..bca7c67b 100644 --- a/toys/posix/find.c +++ b/toys/posix/find.c @@ -457,7 +457,7 @@ static int do_find(struct dirtree *new) } } } else if (!strcmp(s, "user") || !strcmp(s, "group") - || !strcmp(s, "newer") || !strcmp(s, "samefile")) + || !strncmp(s, "newer", 5) || !strcmp(s, "samefile")) { int macoff[] = {offsetof(struct stat, st_mtim), offsetof(struct stat, st_atim), offsetof(struct stat, st_ctim)}; -- 2.39.2