aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-04-14 01:01:20 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-04-14 01:01:20 +0200
commitfe9507f8c39a23e1d0af49eb2ce9466a011aa156 (patch)
tree520a07d356df5b79401ae615d40ad562bfd06a89
parent4eb46e1be6d88eaf077252ce93127ebf00aa8ef2 (diff)
downloadbusybox-w32-fe9507f8c39a23e1d0af49eb2ce9466a011aa156.tar.gz
busybox-w32-fe9507f8c39a23e1d0af49eb2ce9466a011aa156.tar.bz2
busybox-w32-fe9507f8c39a23e1d0af49eb2ce9466a011aa156.zip
touch: fix -am
function old new delta touch_main 414 424 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-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;