diff options
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/mkfifo.c | 4 | ||||
-rw-r--r-- | coreutils/mknod.c | 53 | ||||
-rw-r--r-- | coreutils/printf.c | 2 | ||||
-rw-r--r-- | coreutils/sort.c | 4 | ||||
-rw-r--r-- | coreutils/test.c | 8 | ||||
-rw-r--r-- | coreutils/tr.c | 14 |
6 files changed, 57 insertions, 28 deletions
diff --git a/coreutils/mkfifo.c b/coreutils/mkfifo.c index c74402d4c..b273df046 100644 --- a/coreutils/mkfifo.c +++ b/coreutils/mkfifo.c | |||
@@ -27,10 +27,10 @@ | |||
27 | #include <errno.h> | 27 | #include <errno.h> |
28 | 28 | ||
29 | static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n\n" | 29 | static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n\n" |
30 | "Create the named fifo\n\n" | 30 | "Creates a named pipe (identical to 'mknod name p')\n\n" |
31 | 31 | ||
32 | "Options:\n" | 32 | "Options:\n" |
33 | "\t-m\tcreate the fifo with the specified mode; default = a=rw-umask\n"; | 33 | "\t-m\tcreate the pipe using the specified mode (default a=rw)\n"; |
34 | 34 | ||
35 | extern int mkfifo_main(int argc, char **argv) | 35 | extern int mkfifo_main(int argc, char **argv) |
36 | { | 36 | { |
diff --git a/coreutils/mknod.c b/coreutils/mknod.c index 40f508d33..0c93df64d 100644 --- a/coreutils/mknod.c +++ b/coreutils/mknod.c | |||
@@ -28,23 +28,47 @@ | |||
28 | #include <fcntl.h> | 28 | #include <fcntl.h> |
29 | #include <unistd.h> | 29 | #include <unistd.h> |
30 | 30 | ||
31 | static const char mknod_usage[] = "mknod NAME TYPE MAJOR MINOR\n\n" | 31 | static const char mknod_usage[] = "mknod [OPTIONS] NAME TYPE MAJOR MINOR\n\n" |
32 | "Make block or character special files.\n\n" | 32 | "Create a special file (block, character, or pipe).\n\n" |
33 | "Options:\n" | ||
34 | "\t-m\tcreate the special file using the specified mode (default a=rw)\n\n" | ||
33 | "TYPEs include:\n" | 35 | "TYPEs include:\n" |
34 | "\tb:\tMake a block (buffered) device.\n" | 36 | "\tb:\tMake a block (buffered) device.\n" |
35 | |||
36 | "\tc or u:\tMake a character (un-buffered) device.\n" | 37 | "\tc or u:\tMake a character (un-buffered) device.\n" |
37 | "\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n"; | 38 | "\tp:\tMake a named pipe. MAJOR and MINOR are ignored for named pipes.\n"; |
38 | 39 | ||
39 | int mknod_main(int argc, char **argv) | 40 | int mknod_main(int argc, char **argv) |
40 | { | 41 | { |
42 | char *thisarg; | ||
41 | mode_t mode = 0; | 43 | mode_t mode = 0; |
44 | mode_t perm = 0666; | ||
42 | dev_t dev = 0; | 45 | dev_t dev = 0; |
43 | 46 | ||
44 | if (argc != 5 || **(argv + 1) == '-') { | 47 | argc--; |
48 | argv++; | ||
49 | |||
50 | /* Parse any options */ | ||
51 | while (argc > 1) { | ||
52 | if (**argv != '-') | ||
53 | break; | ||
54 | thisarg = *argv; | ||
55 | thisarg++; | ||
56 | switch (*thisarg) { | ||
57 | case 'm': | ||
58 | argc--; | ||
59 | argv++; | ||
60 | parse_mode(*argv, &perm); | ||
61 | break; | ||
62 | default: | ||
63 | usage(mknod_usage); | ||
64 | } | ||
65 | argc--; | ||
66 | argv++; | ||
67 | } | ||
68 | if (argc != 4 && argc != 2) { | ||
45 | usage(mknod_usage); | 69 | usage(mknod_usage); |
46 | } | 70 | } |
47 | switch (argv[2][0]) { | 71 | switch (argv[1][0]) { |
48 | case 'c': | 72 | case 'c': |
49 | case 'u': | 73 | case 'u': |
50 | mode = S_IFCHR; | 74 | mode = S_IFCHR; |
@@ -54,23 +78,22 @@ int mknod_main(int argc, char **argv) | |||
54 | break; | 78 | break; |
55 | case 'p': | 79 | case 'p': |
56 | mode = S_IFIFO; | 80 | mode = S_IFIFO; |
81 | if (argc!=2) { | ||
82 | usage(mknod_usage); | ||
83 | } | ||
57 | break; | 84 | break; |
58 | default: | 85 | default: |
59 | usage(mknod_usage); | 86 | usage(mknod_usage); |
60 | } | 87 | } |
61 | 88 | ||
62 | if (mode == S_IFCHR || mode == S_IFBLK) { | 89 | if (mode == S_IFCHR || mode == S_IFBLK) { |
63 | dev = (atoi(argv[3]) << 8) | atoi(argv[4]); | 90 | dev = (atoi(argv[2]) << 8) | atoi(argv[1]); |
64 | if (argc != 5) { | ||
65 | usage(mknod_usage); | ||
66 | } | ||
67 | } | 91 | } |
68 | 92 | ||
69 | mode |= 0666; | 93 | mode |= perm; |
70 | 94 | ||
71 | if (mknod(argv[1], mode, dev) != 0) { | 95 | if (mknod(argv[0], mode, dev) != 0) |
72 | perror(argv[1]); | 96 | fatalError("%s: %s\n", argv[0], strerror(errno)); |
73 | exit (FALSE); | ||
74 | } | ||
75 | exit (TRUE); | 97 | exit (TRUE); |
76 | } | 98 | } |
99 | |||
diff --git a/coreutils/printf.c b/coreutils/printf.c index 41ab2e442..bfe408175 100644 --- a/coreutils/printf.c +++ b/coreutils/printf.c | |||
@@ -139,7 +139,7 @@ static void verify __P((char *s, char *end)); | |||
139 | /* The value to return to the calling program. */ | 139 | /* The value to return to the calling program. */ |
140 | static int exit_status; | 140 | static int exit_status; |
141 | 141 | ||
142 | static const char printf_usage[] = "printf format [argument...]\n"; | 142 | static const char printf_usage[] = "printf format [argument...]\n\nFormats and prints the given data.\n"; |
143 | 143 | ||
144 | int printf_main(int argc, char **argv) | 144 | int printf_main(int argc, char **argv) |
145 | { | 145 | { |
diff --git a/coreutils/sort.c b/coreutils/sort.c index 6ee6f207e..4301f4303 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c | |||
@@ -33,7 +33,7 @@ static const char sort_usage[] = "sort [-n]" | |||
33 | #ifdef BB_FEATURE_SORT_REVERSE | 33 | #ifdef BB_FEATURE_SORT_REVERSE |
34 | " [-r]" | 34 | " [-r]" |
35 | #endif | 35 | #endif |
36 | " [FILE]...\n\n"; | 36 | " [FILE]...\n\nSorts lines of text in the specified files\n"; |
37 | 37 | ||
38 | #ifdef BB_FEATURE_SORT_REVERSE | 38 | #ifdef BB_FEATURE_SORT_REVERSE |
39 | #define APPLY_REVERSE(x) (reverse ? -(x) : (x)) | 39 | #define APPLY_REVERSE(x) (reverse ? -(x) : (x)) |
@@ -320,4 +320,4 @@ int sort_main(int argc, char **argv) | |||
320 | exit(0); | 320 | exit(0); |
321 | } | 321 | } |
322 | 322 | ||
323 | /* $Id: sort.c,v 1.13 2000/04/13 01:18:56 erik Exp $ */ | 323 | /* $Id: sort.c,v 1.14 2000/04/15 16:34:54 erik Exp $ */ |
diff --git a/coreutils/test.c b/coreutils/test.c index 85d06a83a..0ed777194 100644 --- a/coreutils/test.c +++ b/coreutils/test.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * echo implementation for busybox | 3 | * test implementation for busybox |
4 | * | 4 | * |
5 | * Copyright (c) by a whole pile of folks: | 5 | * Copyright (c) by a whole pile of folks: |
6 | * | 6 | * |
@@ -185,6 +185,12 @@ test_main(int argc, char** argv) | |||
185 | fatalError("missing ]"); | 185 | fatalError("missing ]"); |
186 | argv[argc] = NULL; | 186 | argv[argc] = NULL; |
187 | } | 187 | } |
188 | if (strcmp(argv[1], "--help") == 0) { | ||
189 | usage("test EXPRESSION\n" | ||
190 | "or [ EXPRESSION ]\n\n" | ||
191 | "Checks file types and compares values returning an exit\n" | ||
192 | "code determined by the value of EXPRESSION.\n"); | ||
193 | } | ||
188 | 194 | ||
189 | /* Implement special cases from POSIX.2, section 4.62.4 */ | 195 | /* Implement special cases from POSIX.2, section 4.62.4 */ |
190 | switch (argc) { | 196 | switch (argc) { |
diff --git a/coreutils/tr.c b/coreutils/tr.c index 3bfa48080..b631b0065 100644 --- a/coreutils/tr.c +++ b/coreutils/tr.c | |||
@@ -44,7 +44,7 @@ static char sccsid[] = "@(#)tr.c 8.2 (Berkeley) 5/4/95"; | |||
44 | #endif | 44 | #endif |
45 | static const char rcsid[] = | 45 | static const char rcsid[] = |
46 | 46 | ||
47 | "$Id: tr.c,v 1.2 2000/03/21 22:32:57 erik Exp $"; | 47 | "$Id: tr.c,v 1.3 2000/04/15 16:34:54 erik Exp $"; |
48 | #endif /* not lint */ | 48 | #endif /* not lint */ |
49 | #endif /* #if 0 */ | 49 | #endif /* #if 0 */ |
50 | 50 | ||
@@ -138,12 +138,12 @@ int cflag; | |||
138 | 138 | ||
139 | static void tr_usage() | 139 | static void tr_usage() |
140 | { | 140 | { |
141 | (void) fprintf(stderr, "%s\n%s\n%s\n%s\n", | 141 | usage( "\ttr [-csu] string1 string2\n" |
142 | "usage: tr [-csu] string1 string2", | 142 | "\ttr [-cu] -d string1\n" |
143 | " tr [-cu] -d string1", | 143 | "\ttr [-cu] -s string1\n" |
144 | " tr [-cu] -s string1", | 144 | "\ttr [-cu] -ds string1 string2\n\n" |
145 | " tr [-cu] -ds string1 string2"); | 145 | "Translate, squeeze, and/or delete characters from standard\n" |
146 | exit(1); | 146 | "input, writing to standard output.\n"); |
147 | } | 147 | } |
148 | 148 | ||
149 | 149 | ||