On Fri, Jun 27, 2025 at 2:16 AM Pádraig Brady <p...@draigbrady.com> wrote:
> On 27/06/2025 06:36, Collin Funk wrote:
> > Creating this bug report since I have not been able to create a working
> > implementation yet, and perhaps my looking into this will inspire others
> > thoughts...
> >
> > POSIX-1.2024 adds the following SYNOPSIS for 'tail' [1]:
> >
> >      tail [-f] [-c number|-n number] [file]
> >      tail -r [-n number] [file]
> >
> > Where the description for '-r' is:
> >
> >      Copy the lines in reverse order (last line first). If -n is
> >      specified, that many lines of the file, starting with the last line,
> >      shall be copied. If -n is not specified, every line of the input
> >      file shall be copied.
> >
> > In a simple implementation of 'tail', one that allocates an array to
> > store each line in memory, this would be easy to implement. However,
> > the Coreutils version reads the file in BUFSIZE/getpagesize() chunks
> > and then prints, repeating until completed. Therefore, we cannot just
> > modify the existing code to swap lines in memory.
> >
> > Collin
> >
> > [1] https://pubs.opengroup.org/onlinepubs/9799919799/utilities/tail.html
>
> tail -r comes from the BSDs.
> Also the BSDs don't have tac(1) which overlaps in functionality quite a bit.
> I'm a bit surprised -r was added by POSIX, but fair enough.

"Surprised" is putting it lightly. I am disappointed and am tempted to
push back and to delay encumbering GNU tail with -r.
That is an option no GNU system needs, since they've all had tac since
before 1992-era textutils.

I've Cc'd Eric Blake, in case someone wants to propose adding tac to
POSIX in spite of the fact that the BSDs still lack it.



Reply via email to