tail: fix tail +N
This commit is contained in:
parent
3f3190e34c
commit
6910741067
@ -122,15 +122,15 @@ int tail_main(int argc, char **argv)
|
|||||||
/* FALLS THROUGH */
|
/* FALLS THROUGH */
|
||||||
case 'n':
|
case 'n':
|
||||||
#if !ENABLE_DEBUG_YANK_SUSv2 || ENABLE_FEATURE_FANCY_TAIL
|
#if !ENABLE_DEBUG_YANK_SUSv2 || ENABLE_FEATURE_FANCY_TAIL
|
||||||
GET_COUNT:
|
GET_COUNT:
|
||||||
#endif
|
#endif
|
||||||
|
from_top = 0;
|
||||||
|
if (*optarg == '+') {
|
||||||
|
++optarg;
|
||||||
|
from_top = 1;
|
||||||
|
}
|
||||||
count = xatol_sfx(optarg, tail_suffixes);
|
count = xatol_sfx(optarg, tail_suffixes);
|
||||||
/* Note: Leading whitespace is an error trapped above. */
|
/* Note: Leading whitespace is an error trapped above. */
|
||||||
if (*optarg == '+') {
|
|
||||||
from_top = 1;
|
|
||||||
} else {
|
|
||||||
from_top = 0;
|
|
||||||
}
|
|
||||||
if (count < 0) {
|
if (count < 0) {
|
||||||
count = -count;
|
count = -count;
|
||||||
}
|
}
|
||||||
@ -150,20 +150,18 @@ int tail_main(int argc, char **argv)
|
|||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
argc -= optind;
|
||||||
|
argv += optind;
|
||||||
|
|
||||||
/* open all the files */
|
/* open all the files */
|
||||||
fds = xmalloc(sizeof(int) * (argc - optind + 1));
|
fds = xmalloc(sizeof(int) * (argc + 1));
|
||||||
|
|
||||||
argv += optind;
|
|
||||||
nfiles = i = 0;
|
nfiles = i = 0;
|
||||||
|
if (argc == 0) {
|
||||||
if ((argc -= optind) == 0) {
|
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|
||||||
if (!fstat(STDIN_FILENO, &statbuf) && S_ISFIFO(statbuf.st_mode)) {
|
if (!fstat(STDIN_FILENO, &statbuf) && S_ISFIFO(statbuf.st_mode)) {
|
||||||
follow = 0;
|
follow = 0;
|
||||||
}
|
}
|
||||||
/* --argv; */
|
|
||||||
*argv = (char *) bb_msg_standard_input;
|
*argv = (char *) bb_msg_standard_input;
|
||||||
goto DO_STDIN;
|
goto DO_STDIN;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user