summaryrefslogtreecommitdiff
path: root/coreutils/head.c
diff options
context:
space:
mode:
authorRobert Griebl2002-05-17 22:18:04 +0000
committerRobert Griebl2002-05-17 22:18:04 +0000
commit13c26fc1a55df2b97062cf370547c4d656e70957 (patch)
treea948e20b6776ca384779aee363db04c02e541be7 /coreutils/head.c
parentc30c5e89cfe9840745a48a50203b3c4fb76c7773 (diff)
downloadbusybox-13c26fc1a55df2b97062cf370547c4d656e70957.zip
busybox-13c26fc1a55df2b97062cf370547c4d656e70957.tar.gz
SUpport old style -[::digit::] options for head and tail
Also make head behave like GNU head (-0/-n 0 is valid)
Diffstat (limited to 'coreutils/head.c')
-rw-r--r--coreutils/head.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/coreutils/head.c b/coreutils/head.c
index 4a16771..c5c11fc 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -47,12 +47,17 @@ int head_main(int argc, char **argv)
FILE *fp;
int need_headers, opt, len = 10, status = EXIT_SUCCESS;
+ if (( argc >= 2 ) && ( strlen ( argv [1] ) >= 2 ) && ( argv [1][0] == '-' ) && isdigit ( argv [1][1] )) {
+ len = atoi ( &argv [1][1] );
+ optind = 2;
+ }
+
/* parse argv[] */
while ((opt = getopt(argc, argv, "n:")) > 0) {
switch (opt) {
case 'n':
len = atoi(optarg);
- if (len >= 1)
+ if (len >= 0)
break;
/* fallthrough */
default: