aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2017-04-06 14:44:45 -0700
committerRob Landley <rob@landley.net>2017-04-11 12:25:13 -0500
commit36b6eb775f8913dbb6ded4fe05a8bfd5e0130a38 (patch)
tree79ed4f9df1327db4a88bb7f5706a47d47b4a14bc /toys
parent0956d16785fd8df1a57d8bf063cddd5b5c1ec221 (diff)
downloadtoybox-36b6eb775f8913dbb6ded4fe05a8bfd5e0130a38.tar.gz
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.
Diffstat (limited to 'toys')
-rw-r--r--toys/posix/touch.c2
1 files changed, 1 insertions, 1 deletions
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;) {