aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtests/touch.test12
-rw-r--r--toys/posix/touch.c2
2 files changed, 10 insertions, 4 deletions
diff --git a/tests/touch.test b/tests/touch.test
index 263e9a0f..da6fe99a 100755
--- a/tests/touch.test
+++ b/tests/touch.test
@@ -64,9 +64,15 @@ testing "-t CCMMDDhhmm" \
"touch -t 2101231234 input && date +%Y-%m-%d:%H-%M-%S -r input" \
"$(date +%C)21-01-23:12-34-00\n" "" ""
+testing "-a" "touch -t 197101020304 walrus &&
+ touch -t 197203040506 -a walrus && stat -c '%X %Y' walrus" \
+ "68562360 31662240\n" "" ""
+testing "-m" "touch -t 197101020304 walrus &&
+ touch -t 197203040506 -m walrus && stat -c '%X %Y' walrus" \
+ "31662240 68562360\n" "" ""
+testing "-am" "touch -t 197101020304 walrus &&
+ touch -t 197203040506 -am walrus && stat -c '%X %Y' walrus" \
+ "68562360 68562360\n" "" ""
-#testing "-a"
-#testing "-m"
-#testing "-am"
#testing "-t"
rm walrus walrus2
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;) {