GNU bug report logs - #47243
pr lacks -p

Previous Next

Package: coreutils;

Reported by: Eric Blake <eblake <at> redhat.com>

Date: Thu, 18 Mar 2021 15:39:01 UTC

Severity: wishlist

Full log


View this message in rfc822 format

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Collin Funk <collin.funk1 <at> gmail.com>, Pádraig Brady <P <at> draigBrady.com>
Cc: 47243 <at> debbugs.gnu.org
Subject: bug#47243: pr lacks -p
Date: Sun, 27 Jul 2025 17:19:18 -0700
Thanks for looking into that. Unfortunately POSIX says -p should be 
ignored only if standard output is a terminal, and that newline should 
be read from /dev/tty, not from standard input. This is so that users 
can pipe into 'pr -p'. So the proposed patch needs some changes. Here 
are the issues I found:


> +  pr now supports the -p option, to pause upon printing each page until
> +  a newline character is read from standard input, as required by POSIX
> +  Issue 6.  The corresponding long option is --pause.

This should be /dev/tty, not standard input.


> +After printing each page, print an alert (bell) to standard error and
> +wait for a newline to be read from standard input before printing the

Likewise.

> +next page.  This option is ignored unless both standard input and
> +standard output are a tty.

This should mention only standard output.


> +  if (pause_option)
> +    pause_option = isatty (STDOUT_FILENO) && isatty (STDIN_FILENO);

This should check only standard output.


> -  if (have_read_stdin && fclose (stdin) == EOF)
> +  if ((have_read_stdin || pause_option) && fclose (stdin) == EOF)
>      error (EXIT_FAILURE, errno, _("standard input"));

This change should be omitted.


> -  while (print_page ())
> -    ;
> +  for (;;)
> +    {
> +      if (pause_option)
> +        {
> +          putc ('\a', stderr);
> +          while (getchar () != '\n')
> +            ;
> +        }
> +      if (! print_page ())
> +        break;
> +    }

This should read from /dev/tty, not from stdin.


> +  -p, --pause       pause at the beginning of each page until a newline\n\
> +                    is read from standard input.\n\

This should mention /dev/tty, not standard input.




This bug report was last modified 8 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.