Subject: bug#47243: pr lacks -p

From: Collin Funk <[email-masked]>
Date: Wed, 30 Jul 2025 20:02:44 -0700

Pádraig Brady <[email-masked]> writes:

> On 30/07/2025 18:31, Paul Eggert wrote:
>> On 2025-07-30 04:18, Pádraig Brady wrote:
>>> 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.
>> Sure, but don't the GNU coding standards disagree with POSIX here?
>> If we
>> follow the GNU coding standards with respect to stdout, then we need a
>> POSIXLY_CORRECT check.
>
>
>> Or are you suggesting that we disregard the coding standards and follow
>> POSIX instead? That would be a reasonable suggestion but we might want
>> to ask RMS about it.
>
> I thought POSIX might have higher priority here when it doesn't
> clash with existing behavior.  As I said I hadn't a strong opinion.

I don't see much of a point in having the pausing behavior occur when
the output is not a terminal. But the GNU Coding Standards say to avoid
it and I don't expect it cause any issues. Maybe someone more clever
than I will find a use for it...

>> While I'm bikeshedding :-), one other thought is that if POSIXLY_CORRECT
>> is not set we could also be compatible with FreeBSD, and output a bell
>> before the first page if -f is specified but -p is not. I suspect that
>> this is a more-useful approach (and could well be what System V did, and
>> we've merely exposed a bug in POSIX here).
> Didn't we discuss that, deciding we need POSIXLY_CORRECT here to gate the incompat behavior.
> I.e. existing scripts may be using -f to use form feeds, and we don't
> want such scripts starting to pause for their first page of output.

FWIW, the pausing from '-f' will not occur unless someone has
POSIXLY_CORRECT set. You can see the behavior by applying the v5 patch
and using the following examples:

    # Doesn't require input.
    $ ./src/pr -f HACKING
    # Requires input
    $ POSIXLY_CORRECT=1 ./src/pr -f HACKING

You can also see a mistake I made that I mentioned in a message to Paul.
Doing 'pr -p HACKING' and pressing Ctrl-D prints the next page, but it
should exit.

> Or do you mean output a bell, but not pause? I can't see how that would be useful?

I think Paul was referring to my mention that FreeBSD and NetBSD print an
alert to standard error when doing 'pr -f', when the POSIX description
only mentions this behavior for 'pr -p'. I'm not certain wether or not
this is allowed by POSIX.

Collin