summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorErik Andersen2000-01-23 18:19:02 +0000
committerErik Andersen2000-01-23 18:19:02 +0000
commit5509af7073ffff75d86ff8c67a2075169a859efd (patch)
tree2728cbb296484026cb657f92f78e1bb0806ba6f4 /coreutils
parent9bc7e89fc1eb493c06494ad86781ab49fc28c509 (diff)
downloadbusybox-5509af7073ffff75d86ff8c67a2075169a859efd.zip
busybox-5509af7073ffff75d86ff8c67a2075169a859efd.tar.gz
* added (and documented) "-n" option for head -
contributed Friedrich Vedder <fwv@myrtle.lahn.de> * Cleanup for a number of usage messages -- also contributed Friedrich Vedder <fwv@myrtle.lahn.de> -Erik
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/du.c4
-rw-r--r--coreutils/head.c28
-rw-r--r--coreutils/mkdir.c3
-rw-r--r--coreutils/sort.c4
-rw-r--r--coreutils/uniq.c4
-rw-r--r--coreutils/wc.c1
6 files changed, 23 insertions, 21 deletions
diff --git a/coreutils/du.c b/coreutils/du.c
index ec03afd..79b5536 100644
--- a/coreutils/du.c
+++ b/coreutils/du.c
@@ -35,7 +35,7 @@
typedef void (Display)(size_t, char *);
static const char du_usage[] =
-"Usage: du [OPTION]... [FILE]...\n\n"
+"du [OPTION]... [FILE]...\n\n"
"\t-s\tdisplay only a total for each argument\n"
;
@@ -140,4 +140,4 @@ du_main(int argc, char **argv)
exit(0);
}
-/* $Id: du.c,v 1.8 1999/12/17 18:44:15 erik Exp $ */
+/* $Id: du.c,v 1.9 2000/01/23 18:19:02 erik Exp $ */
diff --git a/coreutils/head.c b/coreutils/head.c
index 7f08a80..4e58bdc 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -26,10 +26,12 @@
#include <stdio.h>
const char head_usage[] =
-"Usage: head [FILE]...\n\n"
+"head [OPTION] [FILE]...\n\n"
"Print first 10 lines of each FILE to standard output.\n"
"With more than one FILE, precede each with a header giving the\n"
-"file name. With no FILE, or when FILE is -, read standard input.\n";
+"file name. With no FILE, or when FILE is -, read standard input.\n\n"
+"Options:\n"
+"\t-n NUM\t\tPrint first NUM lines instead of first 10\n";
int
head(int len, FILE *src)
@@ -49,22 +51,22 @@ head(int len, FILE *src)
int
head_main(int argc, char **argv)
{
- int i = 1;
char opt;
- int len = 10;
-
- /* 1st option is potentially special */
- if ((argc > 1) && (argv[1][0] == '-') && isDecimal(argv[1][1])) {
- int tmplen = atoi(&argv[1][1]);
- if (tmplen) { len = tmplen; }
- i = 2;
- }
+ int len = 10, tmplen, i;
/* parse argv[] */
- for ( ; i < argc; i++) {
+ for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
opt = argv[i][1];
switch (opt) {
+ case 'n':
+ tmplen = 0;
+ if (i++ < argc)
+ tmplen = atoi(argv[i]);
+ if (tmplen < 1)
+ usage(head_usage);
+ len = tmplen;
+ break;
case '-':
case 'h':
usage(head_usage);
@@ -103,4 +105,4 @@ head_main(int argc, char **argv)
exit(0);
}
-/* $Id: head.c,v 1.4 1999/12/17 18:52:06 erik Exp $ */
+/* $Id: head.c,v 1.5 2000/01/23 18:19:02 erik Exp $ */
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index dc245a1..017ef9b 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -26,7 +26,8 @@
#include <errno.h>
#include <sys/param.h>
-static const char mkdir_usage[] = "Usage: mkdir [OPTION] DIRECTORY...\n\n"
+static const char mkdir_usage[] =
+"mkdir [OPTION] DIRECTORY...\n\n"
"Create the DIRECTORY(ies), if they do not already exist\n\n"
"Options:\n"
"\t-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n"
diff --git a/coreutils/sort.c b/coreutils/sort.c
index 0fe7bf9..4df5627 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -29,7 +29,7 @@
#include <errno.h>
static const char sort_usage[] =
-"Usage: sort [OPTION]... [FILE]...\n\n"
+"sort [OPTION]... [FILE]...\n\n"
;
/* typedefs _______________________________________________________________ */
@@ -309,4 +309,4 @@ sort_main(int argc, char **argv)
exit(0);
}
-/* $Id: sort.c,v 1.8 1999/12/23 22:46:10 beppu Exp $ */
+/* $Id: sort.c,v 1.9 2000/01/23 18:19:02 erik Exp $ */
diff --git a/coreutils/uniq.c b/coreutils/uniq.c
index 034ea31..a7bff54 100644
--- a/coreutils/uniq.c
+++ b/coreutils/uniq.c
@@ -27,7 +27,7 @@
#include <errno.h>
static const char uniq_usage[] =
-"Usage: uniq [OPTION]... [INPUT [OUTPUT]]\n"
+"uniq [OPTION]... [INPUT [OUTPUT]]\n"
"Discard all but one of successive identical lines from INPUT (or\n"
"standard input), writing to OUTPUT (or standard output).\n"
"\n"
@@ -193,4 +193,4 @@ uniq_main(int argc, char **argv)
exit(0);
}
-/* $Id: uniq.c,v 1.4 2000/01/07 01:57:32 beppu Exp $ */
+/* $Id: uniq.c,v 1.5 2000/01/23 18:19:02 erik Exp $ */
diff --git a/coreutils/wc.c b/coreutils/wc.c
index a1e2fca..e69f0d8 100644
--- a/coreutils/wc.c
+++ b/coreutils/wc.c
@@ -28,7 +28,6 @@ static const char wc_usage[] = "wc [OPTION]... [FILE]...\n\n"
"\t-c\tprint the byte counts\n"
"\t-l\tprint the newline counts\n"
"\t-L\tprint the length of the longest line\n"
-"\t-L\tprint the length of the longest line\n"
"\t-w\tprint the word counts\n";
static int total_lines, total_words, total_chars, max_length;