aboutsummaryrefslogtreecommitdiff
path: root/coreutils/touch.c
diff options
context:
space:
mode:
authorXabier Oneca <xoneca@gmail.com>2021-04-10 00:11:46 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-04-13 14:48:24 +0200
commite3c6a0973c8a4fe17d2510093738ef5ae052523e (patch)
tree381be0d34c241c1aeb56ed14ee625e34a2e30f83 /coreutils/touch.c
parent79c92dbd7028a9782b85fcbbbe123e1c44cbaec1 (diff)
downloadbusybox-w32-e3c6a0973c8a4fe17d2510093738ef5ae052523e.tar.gz
busybox-w32-e3c6a0973c8a4fe17d2510093738ef5ae052523e.tar.bz2
busybox-w32-e3c6a0973c8a4fe17d2510093738ef5ae052523e.zip
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>
Diffstat (limited to 'coreutils/touch.c')
-rw-r--r--coreutils/touch.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/coreutils/touch.c b/coreutils/touch.c
index 8d3f8dbbe..189428a79 100644
--- a/coreutils/touch.c
+++ b/coreutils/touch.c
@@ -120,14 +120,18 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
120 * accepted data format differs a bit between -d and -t. 120 * accepted data format differs a bit between -d and -t.
121 * We accept the same formats for both 121 * We accept the same formats for both
122 */ 122 */
123 opts = getopt32long(argv, "c" IF_FEATURE_TOUCH_NODEREF("h") 123 opts = getopt32long(argv, "^"
124 IF_FEATURE_TOUCH_SUSV3("r:d:t:am") 124 "c" IF_FEATURE_TOUCH_NODEREF("h")
125 /*ignored:*/ "f" IF_NOT_FEATURE_TOUCH_SUSV3("am"), 125 IF_FEATURE_TOUCH_SUSV3("r:d:t:am")
126 touch_longopts 126 /*ignored:*/ "f" IF_NOT_FEATURE_TOUCH_SUSV3("am")
127 "\0" /* opt_complementary: */
128 /* coreutils forbids -r and -t at once: */ IF_FEATURE_TOUCH_SUSV3("r--t:t--r")
129 /* but allows these combinations: "r--d:d--r:t--d:d--t" */,
130 touch_longopts
127#if ENABLE_FEATURE_TOUCH_SUSV3 131#if ENABLE_FEATURE_TOUCH_SUSV3
128 , &reference_file 132 , &reference_file
129 , &date_str 133 , &date_str
130 , &date_str 134 , &date_str
131#endif 135#endif
132 ); 136 );
133 137