bug#47243: pr lacks -p

Pádraig Brady <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <[email protected]>
On 30/07/2025 05:51, Collin Funk wrote:
> Paul Eggert <[email protected]> writes:
> 
>>> +After printing each page, print an alert (bell) to standard error and
>>> +wait for a newline to be read from @file{/dev/tty} before printing the
>>> +next page.
>>
>> This sentence should start "Before" not "After", with the rest of the
>> sentence changed accordingly. There is no bell printed after the last
>> page.
>>
>> Looking at the code, it seems that this mistake has leaked into the
>> code as well, in that sometimes 'pr' will print an alert and wait for
>> '\n' at end of file, when there is no page to print. If I'm right,
>> that needs to be fixed; pr should wait for '\n' only if it will
>> actually print something afterward.
> 
> Fixing this required a bit more understanding of the code on my part,
> but I think the attached patch should address it.
> 
> The existing code uses a 'pad_vertically' variable to keep track of
> whether the current page has text or a header that needs to be
> printed. Therefore, any time we set it to true, we must also pause. But
> only once, at the start of the page.

Looking good. A few tweaks...

The NEWS for -p should be in a "New Features" section.

The texinfo for --pause should:
s/before printing the next page/before printing the page/

I'd have a slight preference for _not_ gating the isatty(STDOUT) check on $POSIXLY_CORRECT.
We generally only use $POSIXLY_CORRECT to gate incompatible behavior.

The write_error() after the putc('\a') should be a plain error (EXIT_FAILURE, ...)

thanks,
Padraig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.