From 36b6eb775f8913dbb6ded4fe05a8bfd5e0130a38 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 6 Apr 2017 14:44:45 -0700 Subject: Fix touch -a/-m (and add the missing tests). utimensat takes atime in [0] and mtime in [1], but since we're overwriting with UTIME_OMIT, we actually want to flip the comparison so -a blats 1 and -m blats 0. --- toys/posix/touch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toys/posix/touch.c') diff --git a/toys/posix/touch.c b/toys/posix/touch.c index 79eba177..214d6cf9 100644 --- a/toys/posix/touch.c +++ b/toys/posix/touch.c @@ -111,7 +111,7 @@ void touch_main(void) // Which time(s) should we actually change? i = toys.optflags & (FLAG_a|FLAG_m); - if (i && i!=(FLAG_a|FLAG_m)) ts[i==FLAG_m].tv_nsec = UTIME_OMIT; + if (i && i!=(FLAG_a|FLAG_m)) ts[i!=FLAG_m].tv_nsec = UTIME_OMIT; // Loop through files on command line for (ss = toys.optargs; *ss;) { -- cgit v1.2.3