diff options
author | Xabier Oneca | 2021-04-10 00:11:46 +0200 |
---|---|---|
committer | Denys Vlasenko | 2021-04-13 14:48:24 +0200 |
commit | e3c6a0973c8a4fe17d2510093738ef5ae052523e (patch) | |
tree | 381be0d34c241c1aeb56ed14ee625e34a2e30f83 | |
parent | 79c92dbd7028a9782b85fcbbbe123e1c44cbaec1 (diff) | |
download | busybox-e3c6a0973c8a4fe17d2510093738ef5ae052523e.zip busybox-e3c6a0973c8a4fe17d2510093738ef5ae052523e.tar.gz |
touch: prevent usage of -r and -t at once
coreutils forbids this combination.
Signed-off-by: Xabier Oneca <xoneca@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | coreutils/touch.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/coreutils/touch.c b/coreutils/touch.c index 8d3f8db..189428a 100644 --- a/coreutils/touch.c +++ b/coreutils/touch.c @@ -120,14 +120,18 @@ int touch_main(int argc UNUSED_PARAM, char **argv) * accepted data format differs a bit between -d and -t. * We accept the same formats for both */ - opts = getopt32long(argv, "c" IF_FEATURE_TOUCH_NODEREF("h") - IF_FEATURE_TOUCH_SUSV3("r:d:t:am") - /*ignored:*/ "f" IF_NOT_FEATURE_TOUCH_SUSV3("am"), - touch_longopts + opts = getopt32long(argv, "^" + "c" IF_FEATURE_TOUCH_NODEREF("h") + IF_FEATURE_TOUCH_SUSV3("r:d:t:am") + /*ignored:*/ "f" IF_NOT_FEATURE_TOUCH_SUSV3("am") + "\0" /* opt_complementary: */ + /* coreutils forbids -r and -t at once: */ IF_FEATURE_TOUCH_SUSV3("r--t:t--r") + /* but allows these combinations: "r--d:d--r:t--d:d--t" */, + touch_longopts #if ENABLE_FEATURE_TOUCH_SUSV3 - , &reference_file - , &date_str - , &date_str + , &reference_file + , &date_str + , &date_str #endif ); |