aboutsummaryrefslogtreecommitdiff
path: root/coreutils/touch.c
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils/touch.c')
-rw-r--r--coreutils/touch.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/coreutils/touch.c b/coreutils/touch.c
index 0f980fd7b..1216ca202 100644
--- a/coreutils/touch.c
+++ b/coreutils/touch.c
@@ -7,7 +7,7 @@
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9 9
10/* BB_AUDIT SUSv3 _NOT_ compliant -- options -a, -m, -r, -t not supported. */ 10/* BB_AUDIT SUSv3 _NOT_ compliant -- options -a, -m not supported. */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/touch.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/touch.html */
12 12
13/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) 13/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
@@ -25,18 +25,26 @@
25//config: help 25//config: help
26//config: touch is used to create or change the access and/or 26//config: touch is used to create or change the access and/or
27//config: modification timestamp of specified files. 27//config: modification timestamp of specified files.
28//config:
29//config:config FEATURE_TOUCH_SUSV3
30//config: bool "Add support for SUSV3 features (-d -t -r)"
31//config: default y
32//config: depends on TOUCH
33//config: help
34//config: Enable touch to use a reference file or a given date/time argument.
28 35
29//applet:IF_TOUCH(APPLET_NOFORK(touch, touch, BB_DIR_BIN, BB_SUID_DROP, touch)) 36//applet:IF_TOUCH(APPLET_NOFORK(touch, touch, BB_DIR_BIN, BB_SUID_DROP, touch))
30 37
31//kbuild:lib-$(CONFIG_TOUCH) += touch.o 38//kbuild:lib-$(CONFIG_TOUCH) += touch.o
32 39
33//usage:#define touch_trivial_usage 40//usage:#define touch_trivial_usage
34//usage: "[-c]" IF_DESKTOP(" [-d DATE] [-r FILE]") " FILE [FILE]..." 41//usage: "[-c]" IF_FEATURE_TOUCH_SUSV3(" [-d DATE] [-t DATE] [-r FILE]") " FILE..."
35//usage:#define touch_full_usage "\n\n" 42//usage:#define touch_full_usage "\n\n"
36//usage: "Update the last-modified date on the given FILE[s]\n" 43//usage: "Update the last-modified date on the given FILE[s]\n"
37//usage: "\n -c Don't create files" 44//usage: "\n -c Don't create files"
38//usage: IF_DESKTOP( 45//usage: IF_FEATURE_TOUCH_SUSV3(
39//usage: "\n -d DT Date/time to use" 46//usage: "\n -d DT Date/time to use"
47//usage: "\n -t DT Date/time to use"
40//usage: "\n -r FILE Use FILE's date/time" 48//usage: "\n -r FILE Use FILE's date/time"
41//usage: ) 49//usage: )
42//usage: 50//usage:
@@ -71,7 +79,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
71 int fd; 79 int fd;
72 int status = EXIT_SUCCESS; 80 int status = EXIT_SUCCESS;
73 int opts; 81 int opts;
74#if ENABLE_DESKTOP 82#if ENABLE_FEATURE_TOUCH_SUSV3
75# if ENABLE_LONG_OPTS 83# if ENABLE_LONG_OPTS
76 static const char touch_longopts[] ALIGN1 = 84 static const char touch_longopts[] ALIGN1 =
77 /* name, has_arg, val */ 85 /* name, has_arg, val */
@@ -90,17 +98,17 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
90# define timebuf ((struct timeval*)NULL) 98# define timebuf ((struct timeval*)NULL)
91#endif 99#endif
92 100
93#if ENABLE_DESKTOP && ENABLE_LONG_OPTS 101#if ENABLE_FEATURE_TOUCH_SUSV3 && ENABLE_LONG_OPTS
94 applet_long_options = touch_longopts; 102 applet_long_options = touch_longopts;
95#endif 103#endif
96 /* -d and -t both set time. In coreutils, 104 /* -d and -t both set time. In coreutils,
97 * accepted data format differs a bit between -d and -t. 105 * accepted data format differs a bit between -d and -t.
98 * We accept the same formats for both */ 106 * We accept the same formats for both */
99 opts = getopt32(argv, "c" IF_DESKTOP("r:d:t:") 107 opts = getopt32(argv, "c" IF_FEATURE_TOUCH_SUSV3("r:d:t:")
100 /*ignored:*/ "fma" 108 /*ignored:*/ "fma"
101 IF_DESKTOP(, &reference_file) 109 IF_FEATURE_TOUCH_SUSV3(, &reference_file)
102 IF_DESKTOP(, &date_str) 110 IF_FEATURE_TOUCH_SUSV3(, &date_str)
103 IF_DESKTOP(, &date_str) 111 IF_FEATURE_TOUCH_SUSV3(, &date_str)
104 ); 112 );
105 113
106 opts &= 1; /* only -c bit is left */ 114 opts &= 1; /* only -c bit is left */