touch: fix -am

function                                             old     new   delta
touch_main                                           414     424     +10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2021-04-14 01:01:20 +02:00
parent 4eb46e1be6
commit fe9507f8c3

View File

@ -153,10 +153,13 @@ 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) {
/* 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) {
if (opts & OPT_m)
timebuf[0].tv_nsec = UTIME_OMIT;
}