aboutsummaryrefslogtreecommitdiff
path: root/coreutils/touch.c
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils/touch.c')
-rw-r--r--coreutils/touch.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/coreutils/touch.c b/coreutils/touch.c
index 6c0201374..4c7362acd 100644
--- a/coreutils/touch.c
+++ b/coreutils/touch.c
@@ -153,11 +153,14 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
153 timebuf[1].tv_sec = timebuf[0].tv_sec = t; 153 timebuf[1].tv_sec = timebuf[0].tv_sec = t;
154 timebuf[1].tv_nsec = timebuf[0].tv_nsec = 0; 154 timebuf[1].tv_nsec = timebuf[0].tv_nsec = 0;
155 } 155 }
156 if (opts & OPT_a) { 156 /* If both -a and -m specified, both times should be set.
157 timebuf[1].tv_nsec = UTIME_OMIT; 157 * IOW: set OMIT only if one, not both, of them is given!
158 } 158 */
159 if (opts & OPT_m) { 159 if ((opts & (OPT_a|OPT_m)) != (OPT_a|OPT_m)) {
160 timebuf[0].tv_nsec = UTIME_OMIT; 160 if (opts & OPT_a)
161 timebuf[1].tv_nsec = UTIME_OMIT;
162 if (opts & OPT_m)
163 timebuf[0].tv_nsec = UTIME_OMIT;
161 } 164 }
162 165
163 argv += optind; 166 argv += optind;