tail: fix follow for empty files (thanks cinap_lenrek)
This commit is contained in:
parent
1c835e370f
commit
7ea0732c55
1 changed files with 4 additions and 2 deletions
|
@ -8,6 +8,7 @@
|
||||||
* the simple command tail -c, legal in v10, is illegal
|
* the simple command tail -c, legal in v10, is illegal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
vlong fend;
|
||||||
long count;
|
long count;
|
||||||
int anycount;
|
int anycount;
|
||||||
int follow;
|
int follow;
|
||||||
|
@ -111,7 +112,7 @@ main(int argc, char **argv)
|
||||||
else
|
else
|
||||||
if(units==LINES && origin==BEG)
|
if(units==LINES && origin==BEG)
|
||||||
skip();
|
skip();
|
||||||
if(follow && seekable)
|
if(follow && (seekable || fend == 0))
|
||||||
for(;;) {
|
for(;;) {
|
||||||
static Dir *sb0, *sb1;
|
static Dir *sb0, *sb1;
|
||||||
trunc(sb1, &sb0);
|
trunc(sb1, &sb0);
|
||||||
|
@ -368,5 +369,6 @@ usage(void)
|
||||||
static int
|
static int
|
||||||
isseekable(int fd)
|
isseekable(int fd)
|
||||||
{
|
{
|
||||||
return seek(fd, 0, 2) > 0 && seek(fd, 0, 0) == 0;
|
fend = seek(fd, 0, 2);
|
||||||
|
return fend > 0 && seek(fd, 0, 0) == 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue