mirror of
https://github.com/sheumann/hush.git
synced 2024-12-26 10:32:02 +00:00
SUpport old style -[::digit::] options for head and tail
Also make head behave like GNU head (-0/-n 0 is valid)
This commit is contained in:
parent
c30c5e89cf
commit
13c26fc1a5
@ -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:
|
||||
|
@ -68,6 +68,11 @@ int tail_main(int argc, char **argv)
|
||||
char *s, *start, *end, buf[BUFSIZ];
|
||||
int i, opt;
|
||||
|
||||
if (( argc >= 2 ) && ( strlen ( argv [1] ) >= 2 ) && ( argv [1][0] == '-' ) && isdigit ( argv [1][1] )) {
|
||||
count = atoi ( &argv [1][1] );
|
||||
optind = 2;
|
||||
}
|
||||
|
||||
while ((opt = getopt(argc, argv, "c:fhn:q:s:v")) > 0) {
|
||||
switch (opt) {
|
||||
case 'f':
|
||||
|
Loading…
Reference in New Issue
Block a user