summaryrefslogtreecommitdiff
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 5c54c49..38078d5 100644
--- a/coreutils/cat.c
+++ b/coreutils/cat.c
@@ -42,8 +42,7 @@ extern int cat_more_main(int argc, char **argv)
}
if ( **(argv+1) == '-' ) {
- fprintf(stderr, "Usage: cat [file ...]\n");
- exit(FALSE);
+ usage ("cat [file ...]\n");
}
argc--;
argv++;
diff --git a/coreutils/chroot.c b/coreutils/chroot.c
index 3b6fdae..15f4468 100644
--- a/coreutils/chroot.c
+++ b/coreutils/chroot.c
@@ -33,8 +33,7 @@ static const char chroot_usage[] = "NEWROOT [COMMAND...]\n"
int chroot_main(int argc, char **argv)
{
if ( (argc < 2) || (**(argv+1) == '-') ) {
- fprintf(stderr, "Usage: %s %s", *argv, chroot_usage);
- exit( FALSE);
+ usage( chroot_usage);
}
argc--;
argv++;
diff --git a/coreutils/cp.c b/coreutils/cp.c
index c5e34d3..11c7682 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -60,8 +60,7 @@ extern int cp_main(int argc, char **argv)
{
if (argc < 3) {
- fprintf(stderr, "Usage: %s", cp_usage);
- exit (FALSE);
+ usage (cp_usage);
}
argc--;
argv++;
@@ -85,8 +84,7 @@ extern int cp_main(int argc, char **argv)
recursiveFlag = TRUE;
break;
default:
- fprintf(stderr, "Usage: %s\n", cp_usage);
- exit(FALSE);
+ usage (cp_usage);
}
argc--;
argv++;
diff --git a/coreutils/date.c b/coreutils/date.c
index 2df9e0c..70d5dd5 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -34,7 +34,7 @@
an RFC 822 complient date output for shell scripting
mail commands */
-const char date_usage[] = "Usage: date [OPTION]... [+FORMAT]\n"
+const char date_usage[] = "date [OPTION]... [+FORMAT]\n"
" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
"Display the current time in the given FORMAT, or set the system date.\n"
"\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) {
}
-void
-date_err(void) {
- fprintf (stderr, "%s\n", date_usage);
- exit( FALSE);
-}
-
int
date_main(int argc, char * * argv)
{
@@ -190,7 +184,7 @@ date_main(int argc, char * * argv)
break;
case 's':
set_time = 1;
- if(date_str != NULL) date_err();
+ if(date_str != NULL) usage ( date_usage);
date_str = optarg;
break;
case 'u':
@@ -202,11 +196,11 @@ date_main(int argc, char * * argv)
/* Look ma, no break. Don't fix it either. */
case 'd':
use_arg = 1;
- if(date_str != NULL) date_err();
+ if(date_str != NULL) usage ( date_usage);
date_str = optarg;
break;
case '-':
- date_err();
+ usage ( date_usage);
}
} else {
if ( (date_fmt == NULL) && (strcmp(*argv, "+")==0) )
@@ -215,7 +209,7 @@ date_main(int argc, char * * argv)
set_time = 1;
date_str=*argv;
} else {
- date_err();
+ usage ( date_usage);
}
}
i--;
diff --git a/coreutils/length.c b/coreutils/length.c
index f2dadd2..46242b5 100644
--- a/coreutils/length.c
+++ b/coreutils/length.c
@@ -7,8 +7,7 @@ extern int
length_main(int argc, char * * argv)
{
if ( **(argv+1) == '-' ) {
- fprintf(stderr, "Usage: length string\n");
- exit(FALSE);
+ usage("length string\n");
}
printf("%d\n", strlen(argv[1]));
return( TRUE);
diff --git a/coreutils/ln.c b/coreutils/ln.c
index cd3cb4e..8f7719f 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -44,8 +44,7 @@ extern int ln_main(int argc, char **argv)
char newdestName[NAME_MAX];
if (argc < 3) {
- fprintf(stderr, "Usage: %s", ln_usage);
- exit (FALSE);
+ usage (ln_usage);
}
argc--;
argv++;
@@ -61,8 +60,7 @@ extern int ln_main(int argc, char **argv)
removeoldFlag = TRUE;
break;
default:
- fprintf(stderr, "Usage: %s\n", ln_usage);
- exit(FALSE);
+ usage (ln_usage);
}
argc--;
argv++;
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 2e3d50e..0adc35d 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -19,6 +19,8 @@
*
*/
+// I started writing a newer small one, but it isn't done yet....
+// -Erik
#if fooBar
#include <stdio.h>
@@ -110,8 +112,7 @@ int ls_main(int argc, char **argv)
recursiveFlag = TRUE;
break;
default:
- fprintf(stderr, "Usage: %s\n", ls_usage);
- exit( FALSE);
+ usage (ls_usage);
}
argc--;
argv++;
@@ -571,7 +572,7 @@ listerr:
return 1;
}
-const char ls_usage[] = "Usage: ls [-1a"
+const char ls_usage[] = "ls [-1a"
#ifdef FEATURE_TIMESTAMPS
"c"
#endif
@@ -668,7 +669,7 @@ ls_main(int argc, char * * argv)
exit( i);
print_usage_message:
- fprintf(stderr, "Usage: %s\n", ls_usage);
+ usage (ls_usage);
exit( FALSE);
}
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index 61d35d5..b42899a 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -51,8 +51,7 @@ extern int mkdir_main(int argc, char **argv)
parentFlag = TRUE;
break;
default:
- fprintf(stderr, "%s\n", mkdir_usage);
- exit(FALSE);
+ usage( mkdir_usage);
}
argc--;
argv++;
@@ -60,8 +59,7 @@ extern int mkdir_main(int argc, char **argv)
if (argc < 1) {
- fprintf(stderr, "%s\n", mkdir_usage);
- exit (FALSE);
+ usage( mkdir_usage);
}
while (--argc > 0) {
diff --git a/coreutils/mknod.c b/coreutils/mknod.c
index b18394b..95d7de3 100644
--- a/coreutils/mknod.c
+++ b/coreutils/mknod.c
@@ -1,4 +1,5 @@
#include "internal.h"
+#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -13,7 +14,7 @@ const char mknod_usage[] = "mknod file b|c|u|p major minor\n"
"\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n";
int
-mknod_main(struct FileInfo * i, int argc, char * * argv)
+mknod_main(int argc, char** argv)
{
mode_t mode = 0;
dev_t dev = 0;
@@ -30,23 +31,21 @@ mknod_main(struct FileInfo * i, int argc, char * * argv)
mode = S_IFIFO;
break;
default:
- usage(mknod_usage);
- return 1;
+ usage (mknod_usage);
}
if ( mode == S_IFCHR || mode == S_IFBLK ) {
dev = (atoi(argv[3]) << 8) | atoi(argv[4]);
if ( argc != 5 ) {
- usage(mknod_usage);
- return 1;
+ usage (mknod_usage);
}
}
mode |= 0666;
if ( mknod(argv[1], mode, dev) != 0 ) {
- name_and_error(argv[1]);
- return 1;
+ perror(argv[1]);
+ return( FALSE);
}
- return 0;
+ return( TRUE);
}
diff --git a/coreutils/mv.c b/coreutils/mv.c
index 2a7c8c1..ab3fc2b 100644
--- a/coreutils/mv.c
+++ b/coreutils/mv.c
@@ -42,8 +42,7 @@ extern int mv_main(int argc, char **argv)
char newdestName[NAME_MAX];
if (argc < 3) {
- fprintf(stderr, "Usage: %s", mv_usage);
- exit (FALSE);
+ usage (mv_usage);
}
argc--;
argv++;
diff --git a/coreutils/printf.c b/coreutils/printf.c
index e79843c..4d44659 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -1,8 +1,3 @@
-// I may still need some more cleaning...fix my error checking
-
-#include "internal.h"
-#ifdef BB_PRINTF
-
/* printf - format and print data
Copyright (C) 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
@@ -51,6 +46,7 @@
// 19990508 Busy Boxed! Dave Cinege
+#include "internal.h"
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
@@ -140,15 +136,18 @@ static void verify __P ((char *s, char *end));
/* The value to return to the calling program. */
static int exit_status;
-const char printf_usage[] = "Usage: printf format [argument...]\n";
+const char printf_usage[] = "printf format [argument...]\n";
int
-printf_main(struct FileInfo * i, int argc, char * * argv)
+printf_main(int argc, char** argv)
{
char *format;
int args_used;
exit_status = 0;
+ if ( **(argv+1) == '-' ) {
+ usage (printf_usage);
+ }
format = argv[1];
argc -= 2;
@@ -528,4 +527,3 @@ verify (char *s, char *end)
}
}
-#endif
diff --git a/coreutils/rm.c b/coreutils/rm.c
index 477d3af..dd8dfa4 100644
--- a/coreutils/rm.c
+++ b/coreutils/rm.c
@@ -25,7 +25,7 @@
#include <utime.h>
#include <dirent.h>
-static const char* rm_usage = "Usage: rm [OPTION]... FILE...\n"
+static const char* rm_usage = "rm [OPTION]... FILE...\n"
"Remove (unlink) the FILE(s).\n\n"
"\t-f\tremove existing destinations, never prompt\n"
"\t-r\tremove the contents of directories recursively\n";
@@ -58,8 +58,7 @@ extern int rm_main(int argc, char **argv)
{
if (argc < 2) {
- fprintf(stderr, "Usage: %s", rm_usage);
- exit (FALSE);
+ usage( rm_usage);
}
argc--;
argv++;
@@ -75,8 +74,7 @@ extern int rm_main(int argc, char **argv)
forceFlag = TRUE;
break;
default:
- fprintf(stderr, "Usage: %s\n", rm_usage);
- exit(FALSE);
+ usage( rm_usage);
}
argc--;
argv++;
diff --git a/coreutils/rmdir.c b/coreutils/rmdir.c
index b4da03f..666e047 100644
--- a/coreutils/rmdir.c
+++ b/coreutils/rmdir.c
@@ -27,8 +27,7 @@
extern int rmdir_main(int argc, char **argv)
{
if ( argc==1 || **(argv+1) == '-' ) {
- fprintf(stderr, "Usage: rmdir [OPTION]... DIRECTORY...\nRemove the DIRECTORY(ies), if they are empty.");
- exit(FALSE);
+ usage( "rmdir [OPTION]... DIRECTORY...\nRemove the DIRECTORY(ies), if they are empty.");
}
while (--argc > 0) {
diff --git a/coreutils/sleep.c b/coreutils/sleep.c
index 53fe5a0..7e38a36 100644
--- a/coreutils/sleep.c
+++ b/coreutils/sleep.c
@@ -8,8 +8,7 @@ extern int
sleep_main(int argc, char * * argv)
{
if ( (argc < 2) || (**(argv+1) == '-') ) {
- fprintf(stderr, "Usage: %s %s", *argv, sleep_usage);
- exit(FALSE);
+ usage( sleep_usage );
}
if ( sleep(atoi(*(++argv))) != 0 ) {
diff --git a/coreutils/sync.c b/coreutils/sync.c
index 572d749..8800f2e 100644
--- a/coreutils/sync.c
+++ b/coreutils/sync.c
@@ -5,9 +5,8 @@ extern int
sync_main(int argc, char * * argv)
{
if ( **(argv+1) == '-' ) {
- fprintf(stderr, "Usage: sync\nWrite all buffered filesystem blocks to disk.\n");
- exit(FALSE);
+ usage( "sync\nWrite all buffered filesystem blocks to disk.\n");
}
- return sync();
+ return sync();
}
diff --git a/coreutils/touch.c b/coreutils/touch.c
index 8dac102..c36ffca 100644
--- a/coreutils/touch.c
+++ b/coreutils/touch.c
@@ -40,8 +40,7 @@ touch_main(int argc, char **argv)
int create=TRUE;
if (argc < 2) {
- fprintf(stderr, "Usage: %s %s", *argv, touch_usage);
- exit( FALSE);
+ usage( touch_usage);
}
argc--;
argv++;