[Bug 222671] tail(1): tail -r fails on certain piped input

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu Sep 28 22:51:36 UTC 2017


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=222671

            Bug ID: 222671
           Summary: tail(1): tail -r fails on certain piped input
           Product: Base System
           Version: 11.1-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: freebsd-bugs at FreeBSD.org
          Reporter: freebsd-bugzilla at umpquanet.com

I'm not 100% sure of the conditions, but it appears that when:

1) tail -r is reading from a pipe;

2) the first input on the pipe is a newline (first line is blank)

tail will reverse the output, except it gets the Nth and (N-1)th output lines
wrong.  It places the first line of input (the newline) on the (N-1)th line of
output, and it place the second line of input on the Nth line of output.

$ uname -a
FreeBSD g5.umpquanet.com 11.1-STABLE FreeBSD 11.1-STABLE #0 r321722: Sun Jul 30
12:07:20 PDT 2017     root at g5.umpquanet.com:/usr/obj/usr/src/sys/G5  amd64
$ printf '\n1\n'

1
$ printf '\n1\n' | tail -r

1
$ printf '\n1\n2\n3\n'

1
2
3
$ printf '\n1\n2\n3\n' | tail -r
3
2

1
$ 

I looked at the GitHub mirror and downloaded a few src tarballs around recent
commits to tail.

Building tail from:

https://github.com/freebsd/freebsd/tree/97a2ca501c7e9f07a80339a88fbb5a46977ae428

does not manifest the bug.

However, tail built from:

https://github.com/freebsd/freebsd/tree/2fef72832029bcc228a527dd9c423ba34a7490e9

does.  IANAE, but it appears the bug may have crept in during:

https://reviews.freebsd.org/D9067


HTH,

Jim

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list