diff options
Diffstat (limited to 'coreutils/head.c')
-rw-r--r-- | coreutils/head.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/coreutils/head.c b/coreutils/head.c index 4a1677146..c5c11fc7b 100644 --- a/coreutils/head.c +++ b/coreutils/head.c | |||
@@ -47,12 +47,17 @@ int head_main(int argc, char **argv) | |||
47 | FILE *fp; | 47 | FILE *fp; |
48 | int need_headers, opt, len = 10, status = EXIT_SUCCESS; | 48 | int need_headers, opt, len = 10, status = EXIT_SUCCESS; |
49 | 49 | ||
50 | if (( argc >= 2 ) && ( strlen ( argv [1] ) >= 2 ) && ( argv [1][0] == '-' ) && isdigit ( argv [1][1] )) { | ||
51 | len = atoi ( &argv [1][1] ); | ||
52 | optind = 2; | ||
53 | } | ||
54 | |||
50 | /* parse argv[] */ | 55 | /* parse argv[] */ |
51 | while ((opt = getopt(argc, argv, "n:")) > 0) { | 56 | while ((opt = getopt(argc, argv, "n:")) > 0) { |
52 | switch (opt) { | 57 | switch (opt) { |
53 | case 'n': | 58 | case 'n': |
54 | len = atoi(optarg); | 59 | len = atoi(optarg); |
55 | if (len >= 1) | 60 | if (len >= 0) |
56 | break; | 61 | break; |
57 | /* fallthrough */ | 62 | /* fallthrough */ |
58 | default: | 63 | default: |