bug#47243: pr lacks -p

Collin Funk <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <[email protected]>
Paul Eggert <[email protected]> writes:

> On 2025-07-29 21:51, Collin Funk wrote:
>
>> +          /* Just exit if the user presses Ctrl-D.  */
>> +          if (bytes_read == 0)
>> +            return;
>
> This needs reworking now that 'pause_maybe' is a separate function, as
> the code no longer exits, it just keeps going.

Yep, I noticed just after I sent it. I figured that we could just do:

    if (have_read_stdin && fclose (stdin) == EOF)
      error (EXIT_FAILURE, errno, _("standard input"));
    exit (EXIT_SUCCESS);

The same as we do before exiting 'main' (probably make the closing of
standard input a static function).

But didn't bother sending a new patch just for that. :)

> One other thought. It may well be better to open /dev/tty lazily, that
> is, inside pause_maybe's 'while (true)' loop, just before the 'read'
> (assuming /dev/tty has not already been opened). That way, pr -p
> needn't unnecessarily fail when printing an empty file (where /dev/tty
> isn't needed after all).

Good idea. That sounds better to me as well.

I'll have to take a look at Pádraig's and your other messages in a bit.

Thanks,
Collin
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.