aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/cut.c26
-rw-r--r--coreutils/dirname.c16
-rw-r--r--coreutils/length.c16
-rw-r--r--coreutils/rmdir.c16
-rw-r--r--coreutils/sync.c16
-rw-r--r--coreutils/test.c20
-rw-r--r--coreutils/yes.c16
7 files changed, 69 insertions, 57 deletions
diff --git a/coreutils/cut.c b/coreutils/cut.c
index 783d526a5..08b4586a4 100644
--- a/coreutils/cut.c
+++ b/coreutils/cut.c
@@ -206,6 +206,19 @@ void cut()
206 } 206 }
207} 207}
208 208
209const char cut_usage[] =
210 "cut [OPTION]... [FILE]...\n"
211#ifndef BB_FEATURE_TRIVIAL_HELP
212 "\nPrints selected fields from each input FILE to standard output.\n\n"
213 "Options:\n"
214 "\t-b LIST\tOutput only bytes from LIST\n"
215 "\t-c LIST\tOutput only characters from LIST\n"
216 "\t-d CHAR\tUse CHAR instead of tab as the field delimiter\n"
217 "\t-s\tOnly output Lines if the include DELIM\n"
218 "\t-f N\tPrint only these fields\n"
219 "\t-n\tIgnored\n"
220#endif
221 ;
209 222
210int cut_main(int argc, char **argv) 223int cut_main(int argc, char **argv)
211{ 224{
@@ -213,18 +226,7 @@ int cut_main(int argc, char **argv)
213 int numberFilenames = 0; 226 int numberFilenames = 0;
214 227
215 if (argc == 1 || strcmp(argv[1], dash_dash_help)==0) 228 if (argc == 1 || strcmp(argv[1], dash_dash_help)==0)
216 usage( "cut [OPTION]... [FILE]...\n" 229 usage(cut_usage);
217#ifndef BB_FEATURE_TRIVIAL_HELP
218 "\nPrints selected fields from each input FILE to standard output.\n\n"
219 "Options:\n"
220 "\t-b LIST\tOutput only bytes from LIST\n"
221 "\t-c LIST\tOutput only characters from LIST\n"
222 "\t-d CHAR\tUse CHAR instead of tab as the field delimiter\n"
223 "\t-s\tOnly output Lines if the include DELIM\n"
224 "\t-f N\tPrint only these fields\n"
225 "\t-n\tIgnored\n"
226#endif
227 );
228 230
229 while (i < argc) { 231 while (i < argc) {
230 if (argv[i][0] == '-') { 232 if (argv[i][0] == '-') {
diff --git a/coreutils/dirname.c b/coreutils/dirname.c
index 847842eab..0b60ceb88 100644
--- a/coreutils/dirname.c
+++ b/coreutils/dirname.c
@@ -23,17 +23,19 @@
23#include "internal.h" 23#include "internal.h"
24#include <stdio.h> 24#include <stdio.h>
25 25
26const char dirname_usage[] =
27 "dirname [FILENAME ...]\n"
28#ifndef BB_FEATURE_TRIVIAL_HELP
29 "\nStrips non-directory suffix from FILENAME\n"
30#endif
31 ;
32
26extern int dirname_main(int argc, char **argv) 33extern int dirname_main(int argc, char **argv)
27{ 34{
28 char* s; 35 char* s;
29 36
30 if ((argc < 2) || (**(argv + 1) == '-')) { 37 if ((argc < 2) || (**(argv + 1) == '-'))
31 usage("dirname [FILENAME ...]\n" 38 usage(dirname_usage);
32#ifndef BB_FEATURE_TRIVIAL_HELP
33 "\nStrips non-directory suffix from FILENAME\n"
34#endif
35 );
36 }
37 argv++; 39 argv++;
38 40
39 s=*argv+strlen(*argv)-1; 41 s=*argv+strlen(*argv)-1;
diff --git a/coreutils/length.c b/coreutils/length.c
index c7df21611..82f50c159 100644
--- a/coreutils/length.c
+++ b/coreutils/length.c
@@ -4,15 +4,17 @@
4#include <string.h> 4#include <string.h>
5#include <stdio.h> 5#include <stdio.h>
6 6
7extern int length_main(int argc, char **argv) 7const char length_usage[] =
8{ 8 "length STRING\n"
9 if (argc != 2 || **(argv + 1) == '-') {
10 usage("length STRING\n"
11#ifndef BB_FEATURE_TRIVIAL_HELP 9#ifndef BB_FEATURE_TRIVIAL_HELP
12 "\nPrints out the length of the specified STRING.\n" 10 "\nPrints out the length of the specified STRING.\n"
13#endif 11#endif
14 ); 12 ;
15 } 13
14extern int length_main(int argc, char **argv)
15{
16 if (argc != 2 || **(argv + 1) == '-')
17 usage(length_usage);
16 printf("%lu\n", (long)strlen(argv[1])); 18 printf("%lu\n", (long)strlen(argv[1]));
17 return (TRUE); 19 return (TRUE);
18} 20}
diff --git a/coreutils/rmdir.c b/coreutils/rmdir.c
index 4edb9b6b3..3c3533fae 100644
--- a/coreutils/rmdir.c
+++ b/coreutils/rmdir.c
@@ -26,17 +26,17 @@
26#include <stdio.h> 26#include <stdio.h>
27#include <errno.h> 27#include <errno.h>
28 28
29const char rmdir_usage[] =
30 "rmdir [OPTION]... DIRECTORY...\n"
31#ifndef BB_FEATURE_TRIVIAL_HELP
32 "\nRemove the DIRECTORY(ies), if they are empty.\n"
33#endif
34 ;
29 35
30extern int rmdir_main(int argc, char **argv) 36extern int rmdir_main(int argc, char **argv)
31{ 37{
32 if (argc == 1 || **(argv + 1) == '-') { 38 if (argc == 1 || **(argv + 1) == '-')
33 usage 39 usage(rmdir_usage);
34 ("rmdir [OPTION]... DIRECTORY...\n"
35#ifndef BB_FEATURE_TRIVIAL_HELP
36 "\nRemove the DIRECTORY(ies), if they are empty.\n"
37#endif
38 );
39 }
40 40
41 while (--argc > 0) { 41 while (--argc > 0) {
42 if (rmdir(*(++argv)) == -1) { 42 if (rmdir(*(++argv)) == -1) {
diff --git a/coreutils/sync.c b/coreutils/sync.c
index db35d72fa..f7c14b04c 100644
--- a/coreutils/sync.c
+++ b/coreutils/sync.c
@@ -24,14 +24,16 @@
24#include "internal.h" 24#include "internal.h"
25#include <stdio.h> 25#include <stdio.h>
26 26
27extern int sync_main(int argc, char **argv) 27const char sync_usage[] =
28{ 28 "sync\n"
29 if (argc > 1 && **(argv + 1) == '-') {
30 usage("sync\n"
31#ifndef BB_FEATURE_TRIVIAL_HELP 29#ifndef BB_FEATURE_TRIVIAL_HELP
32 "\nWrite all buffered filesystem blocks to disk.\n" 30 "\nWrite all buffered filesystem blocks to disk.\n"
33#endif 31#endif
34 ); 32 ;
35 } 33
34extern int sync_main(int argc, char **argv)
35{
36 if (argc > 1 && **(argv + 1) == '-')
37 usage(sync_usage);
36 return(sync()); 38 return(sync());
37} 39}
diff --git a/coreutils/test.c b/coreutils/test.c
index 175cb5d05..bf1622cde 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -178,6 +178,15 @@ static int test_eaccess();
178static int is_a_group_member(); 178static int is_a_group_member();
179static void initialize_group_array(); 179static void initialize_group_array();
180 180
181const char test_usage[] =
182 "test EXPRESSION\n"
183 "or [ EXPRESSION ]\n"
184#ifndef BB_FEATURE_TRIVIAL_HELP
185 "\nChecks file types and compares values returning an exit\n"
186 "code determined by the value of EXPRESSION.\n"
187#endif
188 ;
189
181extern int 190extern int
182test_main(int argc, char** argv) 191test_main(int argc, char** argv)
183{ 192{
@@ -188,15 +197,8 @@ test_main(int argc, char** argv)
188 fatalError("missing ]\n"); 197 fatalError("missing ]\n");
189 argv[argc] = NULL; 198 argv[argc] = NULL;
190 } 199 }
191 if (strcmp(argv[1], dash_dash_help) == 0) { 200 if (strcmp(argv[1], dash_dash_help) == 0)
192 usage("test EXPRESSION\n" 201 usage(test_usage);
193 "or [ EXPRESSION ]\n"
194#ifndef BB_FEATURE_TRIVIAL_HELP
195 "\nChecks file types and compares values returning an exit\n"
196 "code determined by the value of EXPRESSION.\n"
197#endif
198 );
199 }
200 202
201 /* Implement special cases from POSIX.2, section 4.62.4 */ 203 /* Implement special cases from POSIX.2, section 4.62.4 */
202 switch (argc) { 204 switch (argc) {
diff --git a/coreutils/yes.c b/coreutils/yes.c
index 1718af4bb..0191bb003 100644
--- a/coreutils/yes.c
+++ b/coreutils/yes.c
@@ -23,17 +23,19 @@
23#include "internal.h" 23#include "internal.h"
24#include <stdio.h> 24#include <stdio.h>
25 25
26const char yes_usage[] =
27 "yes [OPTION]... [STRING]...\n"
28#ifndef BB_FEATURE_TRIVIAL_HELP
29 "\nRepeatedly outputs a line with all specified STRING(s), or `y'.\n"
30#endif
31 ;
32
26extern int yes_main(int argc, char **argv) 33extern int yes_main(int argc, char **argv)
27{ 34{
28 int i; 35 int i;
29 36
30 if (argc >= 2 && *argv[1] == '-') { 37 if (argc >= 2 && *argv[1] == '-')
31 usage("yes [OPTION]... [STRING]...\n" 38 usage(yes_usage);
32#ifndef BB_FEATURE_TRIVIAL_HELP
33 "\nRepeatedly outputs a line with all specified STRING(s), or `y'.\n"
34#endif
35 );
36 }
37 39
38 if (argc == 1) { 40 if (argc == 1) {
39 while (1) 41 while (1)