summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenys Vlasenko2021-04-14 01:01:20 +0200
committerDenys Vlasenko2021-04-14 01:01:20 +0200
commitfe9507f8c39a23e1d0af49eb2ce9466a011aa156 (patch)
tree520a07d356df5b79401ae615d40ad562bfd06a89 /coreutils
parent4eb46e1be6d88eaf077252ce93127ebf00aa8ef2 (diff)
downloadbusybox-fe9507f8c39a23e1d0af49eb2ce9466a011aa156.zip
busybox-fe9507f8c39a23e1d0af49eb2ce9466a011aa156.tar.gz
touch: fix -am
function old new delta touch_main 414 424 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/touch.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/coreutils/touch.c b/coreutils/touch.c
index 6c02013..4c7362a 100644
--- a/coreutils/touch.c
+++ b/coreutils/touch.c
@@ -153,11 +153,14 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
timebuf[1].tv_sec = timebuf[0].tv_sec = t;
timebuf[1].tv_nsec = timebuf[0].tv_nsec = 0;
}
- if (opts & OPT_a) {
- timebuf[1].tv_nsec = UTIME_OMIT;
- }
- if (opts & OPT_m) {
- timebuf[0].tv_nsec = UTIME_OMIT;
+ /* If both -a and -m specified, both times should be set.
+ * IOW: set OMIT only if one, not both, of them is given!
+ */
+ if ((opts & (OPT_a|OPT_m)) != (OPT_a|OPT_m)) {
+ if (opts & OPT_a)
+ timebuf[1].tv_nsec = UTIME_OMIT;
+ if (opts & OPT_m)
+ timebuf[0].tv_nsec = UTIME_OMIT;
}
argv += optind;