bug#47243: pr lacks -p

Paul Eggert <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Organization UCLA Computer Science Department
Message-ID <[email protected]>
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.
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.