Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Sep 2017 22:51:35 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 222671] tail(1): tail -r fails on certain piped input
Message-ID:  <bug-222671-8@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D222671

            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@FreeBSD.org
          Reporter: freebsd-bugzilla@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 lin=
es
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 Ju=
l 30
12:07:20 PDT 2017     root@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
$=20

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

Building tail from:

https://github.com/freebsd/freebsd/tree/97a2ca501c7e9f07a80339a88fbb5a46977=
ae428

does not manifest the bug.

However, tail built from:

https://github.com/freebsd/freebsd/tree/2fef72832029bcc228a527dd9c423ba34a7=
490e9

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

https://reviews.freebsd.org/D9067


HTH,

Jim

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-222671-8>