aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/cat.c3
-rw-r--r--coreutils/chroot.c3
-rw-r--r--coreutils/cp.c6
-rw-r--r--coreutils/date.c16
-rw-r--r--coreutils/length.c3
-rw-r--r--coreutils/ln.c6
-rw-r--r--coreutils/ls.c9
-rw-r--r--coreutils/mkdir.c6
-rw-r--r--coreutils/mknod.c15
-rw-r--r--coreutils/mv.c3
-rw-r--r--coreutils/printf.c14
-rw-r--r--coreutils/rm.c8
-rw-r--r--coreutils/rmdir.c3
-rw-r--r--coreutils/sleep.c3
-rw-r--r--coreutils/sync.c5
-rw-r--r--coreutils/touch.c3
16 files changed, 41 insertions, 65 deletions
diff --git a/coreutils/cat.c b/coreutils/cat.c
index 5c54c4941..38078d505 100644
--- a/coreutils/cat.c
+++ b/coreutils/cat.c
@@ -42,8 +42,7 @@ extern int cat_more_main(int argc, char **argv)
42 } 42 }
43 43
44 if ( **(argv+1) == '-' ) { 44 if ( **(argv+1) == '-' ) {
45 fprintf(stderr, "Usage: cat [file ...]\n"); 45 usage ("cat [file ...]\n");
46 exit(FALSE);
47 } 46 }
48 argc--; 47 argc--;
49 argv++; 48 argv++;
diff --git a/coreutils/chroot.c b/coreutils/chroot.c
index 3b6fdae3b..15f446881 100644
--- a/coreutils/chroot.c
+++ b/coreutils/chroot.c
@@ -33,8 +33,7 @@ static const char chroot_usage[] = "NEWROOT [COMMAND...]\n"
33int chroot_main(int argc, char **argv) 33int chroot_main(int argc, char **argv)
34{ 34{
35 if ( (argc < 2) || (**(argv+1) == '-') ) { 35 if ( (argc < 2) || (**(argv+1) == '-') ) {
36 fprintf(stderr, "Usage: %s %s", *argv, chroot_usage); 36 usage( chroot_usage);
37 exit( FALSE);
38 } 37 }
39 argc--; 38 argc--;
40 argv++; 39 argv++;
diff --git a/coreutils/cp.c b/coreutils/cp.c
index c5e34d333..11c76825c 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -60,8 +60,7 @@ extern int cp_main(int argc, char **argv)
60{ 60{
61 61
62 if (argc < 3) { 62 if (argc < 3) {
63 fprintf(stderr, "Usage: %s", cp_usage); 63 usage (cp_usage);
64 exit (FALSE);
65 } 64 }
66 argc--; 65 argc--;
67 argv++; 66 argv++;
@@ -85,8 +84,7 @@ extern int cp_main(int argc, char **argv)
85 recursiveFlag = TRUE; 84 recursiveFlag = TRUE;
86 break; 85 break;
87 default: 86 default:
88 fprintf(stderr, "Usage: %s\n", cp_usage); 87 usage (cp_usage);
89 exit(FALSE);
90 } 88 }
91 argc--; 89 argc--;
92 argv++; 90 argv++;
diff --git a/coreutils/date.c b/coreutils/date.c
index 2df9e0cc7..70d5dd5c6 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -34,7 +34,7 @@
34 an RFC 822 complient date output for shell scripting 34 an RFC 822 complient date output for shell scripting
35 mail commands */ 35 mail commands */
36 36
37const char date_usage[] = "Usage: date [OPTION]... [+FORMAT]\n" 37const char date_usage[] = "date [OPTION]... [+FORMAT]\n"
38" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n" 38" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
39"Display the current time in the given FORMAT, or set the system date.\n" 39"Display the current time in the given FORMAT, or set the system date.\n"
40"\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n" 40"\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n"
@@ -159,12 +159,6 @@ date_conv_ftime(struct tm *tm_time, const char *t_string) {
159} 159}
160 160
161 161
162void
163date_err(void) {
164 fprintf (stderr, "%s\n", date_usage);
165 exit( FALSE);
166}
167
168int 162int
169date_main(int argc, char * * argv) 163date_main(int argc, char * * argv)
170{ 164{
@@ -190,7 +184,7 @@ date_main(int argc, char * * argv)
190 break; 184 break;
191 case 's': 185 case 's':
192 set_time = 1; 186 set_time = 1;
193 if(date_str != NULL) date_err(); 187 if(date_str != NULL) usage ( date_usage);
194 date_str = optarg; 188 date_str = optarg;
195 break; 189 break;
196 case 'u': 190 case 'u':
@@ -202,11 +196,11 @@ date_main(int argc, char * * argv)
202 /* Look ma, no break. Don't fix it either. */ 196 /* Look ma, no break. Don't fix it either. */
203 case 'd': 197 case 'd':
204 use_arg = 1; 198 use_arg = 1;
205 if(date_str != NULL) date_err(); 199 if(date_str != NULL) usage ( date_usage);
206 date_str = optarg; 200 date_str = optarg;
207 break; 201 break;
208 case '-': 202 case '-':
209 date_err(); 203 usage ( date_usage);
210 } 204 }
211 } else { 205 } else {
212 if ( (date_fmt == NULL) && (strcmp(*argv, "+")==0) ) 206 if ( (date_fmt == NULL) && (strcmp(*argv, "+")==0) )
@@ -215,7 +209,7 @@ date_main(int argc, char * * argv)
215 set_time = 1; 209 set_time = 1;
216 date_str=*argv; 210 date_str=*argv;
217 } else { 211 } else {
218 date_err(); 212 usage ( date_usage);
219 } 213 }
220 } 214 }
221 i--; 215 i--;
diff --git a/coreutils/length.c b/coreutils/length.c
index f2dadd25c..46242b529 100644
--- a/coreutils/length.c
+++ b/coreutils/length.c
@@ -7,8 +7,7 @@ extern int
7length_main(int argc, char * * argv) 7length_main(int argc, char * * argv)
8{ 8{
9 if ( **(argv+1) == '-' ) { 9 if ( **(argv+1) == '-' ) {
10 fprintf(stderr, "Usage: length string\n"); 10 usage("length string\n");
11 exit(FALSE);
12 } 11 }
13 printf("%d\n", strlen(argv[1])); 12 printf("%d\n", strlen(argv[1]));
14 return( TRUE); 13 return( TRUE);
diff --git a/coreutils/ln.c b/coreutils/ln.c
index cd3cb4e45..8f7719fa4 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -44,8 +44,7 @@ extern int ln_main(int argc, char **argv)
44 char newdestName[NAME_MAX]; 44 char newdestName[NAME_MAX];
45 45
46 if (argc < 3) { 46 if (argc < 3) {
47 fprintf(stderr, "Usage: %s", ln_usage); 47 usage (ln_usage);
48 exit (FALSE);
49 } 48 }
50 argc--; 49 argc--;
51 argv++; 50 argv++;
@@ -61,8 +60,7 @@ extern int ln_main(int argc, char **argv)
61 removeoldFlag = TRUE; 60 removeoldFlag = TRUE;
62 break; 61 break;
63 default: 62 default:
64 fprintf(stderr, "Usage: %s\n", ln_usage); 63 usage (ln_usage);
65 exit(FALSE);
66 } 64 }
67 argc--; 65 argc--;
68 argv++; 66 argv++;
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 2e3d50e9f..0adc35de1 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -19,6 +19,8 @@
19 * 19 *
20 */ 20 */
21 21
22// I started writing a newer small one, but it isn't done yet....
23// -Erik
22#if fooBar 24#if fooBar
23 25
24#include <stdio.h> 26#include <stdio.h>
@@ -110,8 +112,7 @@ int ls_main(int argc, char **argv)
110 recursiveFlag = TRUE; 112 recursiveFlag = TRUE;
111 break; 113 break;
112 default: 114 default:
113 fprintf(stderr, "Usage: %s\n", ls_usage); 115 usage (ls_usage);
114 exit( FALSE);
115 } 116 }
116 argc--; 117 argc--;
117 argv++; 118 argv++;
@@ -571,7 +572,7 @@ listerr:
571 return 1; 572 return 1;
572} 573}
573 574
574const char ls_usage[] = "Usage: ls [-1a" 575const char ls_usage[] = "ls [-1a"
575#ifdef FEATURE_TIMESTAMPS 576#ifdef FEATURE_TIMESTAMPS
576 "c" 577 "c"
577#endif 578#endif
@@ -668,7 +669,7 @@ ls_main(int argc, char * * argv)
668 exit( i); 669 exit( i);
669 670
670print_usage_message: 671print_usage_message:
671 fprintf(stderr, "Usage: %s\n", ls_usage); 672 usage (ls_usage);
672 exit( FALSE); 673 exit( FALSE);
673} 674}
674 675
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index 61d35d5cd..b42899a4a 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -51,8 +51,7 @@ extern int mkdir_main(int argc, char **argv)
51 parentFlag = TRUE; 51 parentFlag = TRUE;
52 break; 52 break;
53 default: 53 default:
54 fprintf(stderr, "%s\n", mkdir_usage); 54 usage( mkdir_usage);
55 exit(FALSE);
56 } 55 }
57 argc--; 56 argc--;
58 argv++; 57 argv++;
@@ -60,8 +59,7 @@ extern int mkdir_main(int argc, char **argv)
60 59
61 60
62 if (argc < 1) { 61 if (argc < 1) {
63 fprintf(stderr, "%s\n", mkdir_usage); 62 usage( mkdir_usage);
64 exit (FALSE);
65 } 63 }
66 64
67 while (--argc > 0) { 65 while (--argc > 0) {
diff --git a/coreutils/mknod.c b/coreutils/mknod.c
index b18394bec..95d7de360 100644
--- a/coreutils/mknod.c
+++ b/coreutils/mknod.c
@@ -1,4 +1,5 @@
1#include "internal.h" 1#include "internal.h"
2#include <stdio.h>
2#include <errno.h> 3#include <errno.h>
3#include <sys/types.h> 4#include <sys/types.h>
4#include <sys/stat.h> 5#include <sys/stat.h>
@@ -13,7 +14,7 @@ const char mknod_usage[] = "mknod file b|c|u|p major minor\n"
13"\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n"; 14"\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n";
14 15
15int 16int
16mknod_main(struct FileInfo * i, int argc, char * * argv) 17mknod_main(int argc, char** argv)
17{ 18{
18 mode_t mode = 0; 19 mode_t mode = 0;
19 dev_t dev = 0; 20 dev_t dev = 0;
@@ -30,23 +31,21 @@ mknod_main(struct FileInfo * i, int argc, char * * argv)
30 mode = S_IFIFO; 31 mode = S_IFIFO;
31 break; 32 break;
32 default: 33 default:
33 usage(mknod_usage); 34 usage (mknod_usage);
34 return 1;
35 } 35 }
36 36
37 if ( mode == S_IFCHR || mode == S_IFBLK ) { 37 if ( mode == S_IFCHR || mode == S_IFBLK ) {
38 dev = (atoi(argv[3]) << 8) | atoi(argv[4]); 38 dev = (atoi(argv[3]) << 8) | atoi(argv[4]);
39 if ( argc != 5 ) { 39 if ( argc != 5 ) {
40 usage(mknod_usage); 40 usage (mknod_usage);
41 return 1;
42 } 41 }
43 } 42 }
44 43
45 mode |= 0666; 44 mode |= 0666;
46 45
47 if ( mknod(argv[1], mode, dev) != 0 ) { 46 if ( mknod(argv[1], mode, dev) != 0 ) {
48 name_and_error(argv[1]); 47 perror(argv[1]);
49 return 1; 48 return( FALSE);
50 } 49 }
51 return 0; 50 return( TRUE);
52} 51}
diff --git a/coreutils/mv.c b/coreutils/mv.c
index 2a7c8c1f3..ab3fc2bd5 100644
--- a/coreutils/mv.c
+++ b/coreutils/mv.c
@@ -42,8 +42,7 @@ extern int mv_main(int argc, char **argv)
42 char newdestName[NAME_MAX]; 42 char newdestName[NAME_MAX];
43 43
44 if (argc < 3) { 44 if (argc < 3) {
45 fprintf(stderr, "Usage: %s", mv_usage); 45 usage (mv_usage);
46 exit (FALSE);
47 } 46 }
48 argc--; 47 argc--;
49 argv++; 48 argv++;
diff --git a/coreutils/printf.c b/coreutils/printf.c
index e79843c80..4d4465943 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -1,8 +1,3 @@
1// I may still need some more cleaning...fix my error checking
2
3#include "internal.h"
4#ifdef BB_PRINTF
5
6/* printf - format and print data 1/* printf - format and print data
7 Copyright (C) 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. 2 Copyright (C) 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
8 3
@@ -51,6 +46,7 @@
51 46
52// 19990508 Busy Boxed! Dave Cinege 47// 19990508 Busy Boxed! Dave Cinege
53 48
49#include "internal.h"
54#include <unistd.h> 50#include <unistd.h>
55#include <stdio.h> 51#include <stdio.h>
56#include <sys/types.h> 52#include <sys/types.h>
@@ -140,15 +136,18 @@ static void verify __P ((char *s, char *end));
140/* The value to return to the calling program. */ 136/* The value to return to the calling program. */
141static int exit_status; 137static int exit_status;
142 138
143const char printf_usage[] = "Usage: printf format [argument...]\n"; 139const char printf_usage[] = "printf format [argument...]\n";
144 140
145int 141int
146printf_main(struct FileInfo * i, int argc, char * * argv) 142printf_main(int argc, char** argv)
147{ 143{
148 char *format; 144 char *format;
149 int args_used; 145 int args_used;
150 146
151 exit_status = 0; 147 exit_status = 0;
148 if ( **(argv+1) == '-' ) {
149 usage (printf_usage);
150 }
152 151
153 format = argv[1]; 152 format = argv[1];
154 argc -= 2; 153 argc -= 2;
@@ -528,4 +527,3 @@ verify (char *s, char *end)
528 } 527 }
529} 528}
530 529
531#endif
diff --git a/coreutils/rm.c b/coreutils/rm.c
index 477d3af59..dd8dfa4e6 100644
--- a/coreutils/rm.c
+++ b/coreutils/rm.c
@@ -25,7 +25,7 @@
25#include <utime.h> 25#include <utime.h>
26#include <dirent.h> 26#include <dirent.h>
27 27
28static const char* rm_usage = "Usage: rm [OPTION]... FILE...\n" 28static const char* rm_usage = "rm [OPTION]... FILE...\n"
29"Remove (unlink) the FILE(s).\n\n" 29"Remove (unlink) the FILE(s).\n\n"
30"\t-f\tremove existing destinations, never prompt\n" 30"\t-f\tremove existing destinations, never prompt\n"
31"\t-r\tremove the contents of directories recursively\n"; 31"\t-r\tremove the contents of directories recursively\n";
@@ -58,8 +58,7 @@ extern int rm_main(int argc, char **argv)
58{ 58{
59 59
60 if (argc < 2) { 60 if (argc < 2) {
61 fprintf(stderr, "Usage: %s", rm_usage); 61 usage( rm_usage);
62 exit (FALSE);
63 } 62 }
64 argc--; 63 argc--;
65 argv++; 64 argv++;
@@ -75,8 +74,7 @@ extern int rm_main(int argc, char **argv)
75 forceFlag = TRUE; 74 forceFlag = TRUE;
76 break; 75 break;
77 default: 76 default:
78 fprintf(stderr, "Usage: %s\n", rm_usage); 77 usage( rm_usage);
79 exit(FALSE);
80 } 78 }
81 argc--; 79 argc--;
82 argv++; 80 argv++;
diff --git a/coreutils/rmdir.c b/coreutils/rmdir.c
index b4da03f12..666e0476a 100644
--- a/coreutils/rmdir.c
+++ b/coreutils/rmdir.c
@@ -27,8 +27,7 @@
27extern int rmdir_main(int argc, char **argv) 27extern int rmdir_main(int argc, char **argv)
28{ 28{
29 if ( argc==1 || **(argv+1) == '-' ) { 29 if ( argc==1 || **(argv+1) == '-' ) {
30 fprintf(stderr, "Usage: rmdir [OPTION]... DIRECTORY...\nRemove the DIRECTORY(ies), if they are empty."); 30 usage( "rmdir [OPTION]... DIRECTORY...\nRemove the DIRECTORY(ies), if they are empty.");
31 exit(FALSE);
32 } 31 }
33 32
34 while (--argc > 0) { 33 while (--argc > 0) {
diff --git a/coreutils/sleep.c b/coreutils/sleep.c
index 53fe5a0c2..7e38a3667 100644
--- a/coreutils/sleep.c
+++ b/coreutils/sleep.c
@@ -8,8 +8,7 @@ extern int
8sleep_main(int argc, char * * argv) 8sleep_main(int argc, char * * argv)
9{ 9{
10 if ( (argc < 2) || (**(argv+1) == '-') ) { 10 if ( (argc < 2) || (**(argv+1) == '-') ) {
11 fprintf(stderr, "Usage: %s %s", *argv, sleep_usage); 11 usage( sleep_usage );
12 exit(FALSE);
13 } 12 }
14 13
15 if ( sleep(atoi(*(++argv))) != 0 ) { 14 if ( sleep(atoi(*(++argv))) != 0 ) {
diff --git a/coreutils/sync.c b/coreutils/sync.c
index 572d74924..8800f2e76 100644
--- a/coreutils/sync.c
+++ b/coreutils/sync.c
@@ -5,9 +5,8 @@ extern int
5sync_main(int argc, char * * argv) 5sync_main(int argc, char * * argv)
6{ 6{
7 if ( **(argv+1) == '-' ) { 7 if ( **(argv+1) == '-' ) {
8 fprintf(stderr, "Usage: sync\nWrite all buffered filesystem blocks to disk.\n"); 8 usage( "sync\nWrite all buffered filesystem blocks to disk.\n");
9 exit(FALSE);
10 } 9 }
11 return sync(); 10 return sync();
12} 11}
13 12
diff --git a/coreutils/touch.c b/coreutils/touch.c
index 8dac10294..c36ffca90 100644
--- a/coreutils/touch.c
+++ b/coreutils/touch.c
@@ -40,8 +40,7 @@ touch_main(int argc, char **argv)
40 int create=TRUE; 40 int create=TRUE;
41 41
42 if (argc < 2) { 42 if (argc < 2) {
43 fprintf(stderr, "Usage: %s %s", *argv, touch_usage); 43 usage( touch_usage);
44 exit( FALSE);
45 } 44 }
46 argc--; 45 argc--;
47 argv++; 46 argv++;