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()
}
}
+const char cut_usage[] =
+ "cut [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrints selected fields from each input FILE to standard output.\n\n"
+ "Options:\n"
+ "\t-b LIST\tOutput only bytes from LIST\n"
+ "\t-c LIST\tOutput only characters from LIST\n"
+ "\t-d CHAR\tUse CHAR instead of tab as the field delimiter\n"
+ "\t-s\tOnly output Lines if the include DELIM\n"
+ "\t-f N\tPrint only these fields\n"
+ "\t-n\tIgnored\n"
+#endif
+ ;
int cut_main(int argc, char **argv)
{
@@ -213,18 +226,7 @@ int cut_main(int argc, char **argv)
int numberFilenames = 0;
if (argc == 1 || strcmp(argv[1], dash_dash_help)==0)
- usage( "cut [OPTION]... [FILE]...\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
- "\nPrints selected fields from each input FILE to standard output.\n\n"
- "Options:\n"
- "\t-b LIST\tOutput only bytes from LIST\n"
- "\t-c LIST\tOutput only characters from LIST\n"
- "\t-d CHAR\tUse CHAR instead of tab as the field delimiter\n"
- "\t-s\tOnly output Lines if the include DELIM\n"
- "\t-f N\tPrint only these fields\n"
- "\t-n\tIgnored\n"
-#endif
- );
+ usage(cut_usage);
while (i < argc) {
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 @@
#include "internal.h"
#include <stdio.h>
+const char dirname_usage[] =
+ "dirname [FILENAME ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nStrips non-directory suffix from FILENAME\n"
+#endif
+ ;
+
extern int dirname_main(int argc, char **argv)
{
char* s;
- if ((argc < 2) || (**(argv + 1) == '-')) {
- usage("dirname [FILENAME ...]\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
- "\nStrips non-directory suffix from FILENAME\n"
-#endif
- );
- }
+ if ((argc < 2) || (**(argv + 1) == '-'))
+ usage(dirname_usage);
argv++;
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 @@
#include <string.h>
#include <stdio.h>
-extern int length_main(int argc, char **argv)
-{
- if (argc != 2 || **(argv + 1) == '-') {
- usage("length STRING\n"
+const char length_usage[] =
+ "length STRING\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
- "\nPrints out the length of the specified STRING.\n"
+ "\nPrints out the length of the specified STRING.\n"
#endif
- );
- }
+ ;
+
+extern int length_main(int argc, char **argv)
+{
+ if (argc != 2 || **(argv + 1) == '-')
+ usage(length_usage);
printf("%lu\n", (long)strlen(argv[1]));
return (TRUE);
}
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 @@
#include <stdio.h>
#include <errno.h>
+const char rmdir_usage[] =
+ "rmdir [OPTION]... DIRECTORY...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nRemove the DIRECTORY(ies), if they are empty.\n"
+#endif
+ ;
extern int rmdir_main(int argc, char **argv)
{
- if (argc == 1 || **(argv + 1) == '-') {
- usage
- ("rmdir [OPTION]... DIRECTORY...\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
- "\nRemove the DIRECTORY(ies), if they are empty.\n"
-#endif
- );
- }
+ if (argc == 1 || **(argv + 1) == '-')
+ usage(rmdir_usage);
while (--argc > 0) {
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 @@
#include "internal.h"
#include <stdio.h>
-extern int sync_main(int argc, char **argv)
-{
- if (argc > 1 && **(argv + 1) == '-') {
- usage("sync\n"
+const char sync_usage[] =
+ "sync\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
- "\nWrite all buffered filesystem blocks to disk.\n"
+ "\nWrite all buffered filesystem blocks to disk.\n"
#endif
- );
- }
+ ;
+
+extern int sync_main(int argc, char **argv)
+{
+ if (argc > 1 && **(argv + 1) == '-')
+ usage(sync_usage);
return(sync());
}
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();
static int is_a_group_member();
static void initialize_group_array();
+const char test_usage[] =
+ "test EXPRESSION\n"
+ "or [ EXPRESSION ]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nChecks file types and compares values returning an exit\n"
+ "code determined by the value of EXPRESSION.\n"
+#endif
+ ;
+
extern int
test_main(int argc, char** argv)
{
@@ -188,15 +197,8 @@ test_main(int argc, char** argv)
fatalError("missing ]\n");
argv[argc] = NULL;
}
- if (strcmp(argv[1], dash_dash_help) == 0) {
- usage("test EXPRESSION\n"
- "or [ EXPRESSION ]\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
- "\nChecks file types and compares values returning an exit\n"
- "code determined by the value of EXPRESSION.\n"
-#endif
- );
- }
+ if (strcmp(argv[1], dash_dash_help) == 0)
+ usage(test_usage);
/* Implement special cases from POSIX.2, section 4.62.4 */
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 @@
#include "internal.h"
#include <stdio.h>
+const char yes_usage[] =
+ "yes [OPTION]... [STRING]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nRepeatedly outputs a line with all specified STRING(s), or `y'.\n"
+#endif
+ ;
+
extern int yes_main(int argc, char **argv)
{
int i;
- if (argc >= 2 && *argv[1] == '-') {
- usage("yes [OPTION]... [STRING]...\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
- "\nRepeatedly outputs a line with all specified STRING(s), or `y'.\n"
-#endif
- );
- }
+ if (argc >= 2 && *argv[1] == '-')
+ usage(yes_usage);
if (argc == 1) {
while (1)