[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#363250: general: Custom PAGER gives error on sid, but works on sarge



clone 363250 -1
reassign -1 general
retitle -1 PAGER as a pipeline
tags 363250 fixed-upstream
thanks

On Sun, Apr 23, 2006 at 09:52:34PM +0200, Loïc Minier wrote:
>  Yes, indeed, the root of the problem is the change of support for
>  pipelines.  However, I'm not sure that pipelines worked in the use case
>  of passing a file as a parameter to $PAGER in the past.
> 
>  Currently, each program (for example man) has its way of calling
>  $PAGER, perhaps as "$PAGER <file name>" or piping to "sh -c "$PAGER"",
>  or perhaps piping directly to "$PAGER".
> 
>  Of course, if we say $PAGER can be a pipeline, and a pager can be used
>  both as "$PAGER <file name>" and as the end of a pipeline, then
>  defining $PAGER to be a pipeline must work in both cases, but I'm not
>  sure it is a regression to not support pipelines in the use case of a
>  file name as argument.
> 
>  In other words:
> 
>                                 $PAGER is a             $PAGER is a
>                                 program                 pipeline
>  ====================================================================
>  call $PAGER as                 works                   ???
>  $PAGER <file name>
>  ====================================================================
>  call $PAGER as
>  cat <data> | $PAGER            works                   works

That last entry is not correct. See below.

>  I do agree that the two use cases that you listed in a previous message
>  exist, I'm not sure they were both supported in the case where $PAGER
>  is a pipeline, but we can work on fixing that at least in
>  sensible-pager by using systematically: cat "$@" | $PAGER

Sorry I took so long to deal with this bug report against man-db. I must
confess that the length of the thread intimidated me a bit!

For the meantime, I note that putting pipes in $PAGER doesn't work even
with sensible-pager, since variable expansion doesn't work that way in
shell:

  $ cat f
  foo
  bar
  $ PAGER='cat | grep bar' sensible-pager f
  cat: |: No such file or directory
  cat: grep: No such file or directory
  cat: bar: No such file or directory
  foo
  bar
  $ PAGER='cat | grep bar' <f sensible-pager
  cat: |: No such file or directory
  cat: grep: No such file or directory
  cat: bar: No such file or directory

To be precise, expansion happens after shell input is parsed into
commands. See:

  http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_01

I therefore don't think it makes sense to do the not inconsiderable
amount of work required to support pipes-in-$PAGER in man-db when even
sensible-pager can't cope wth it. (The reason it used to work was that
man-db used to be very sloppy about all sorts of things and just passed
stuff to system(); over the last few years I taught it how to handle
pipelined command execution itself, which fixed a wide variety of
interesting bugs. As a result, though, pipes in $PAGER and other things
that man-db interprets stopped being supported.)

For the meantime, I've simply documented the constraints on PAGER and
friends in man(1), and advised the use of a script in such cases:

Tue Jul 21 15:17:49 BST 2009  Colin Watson  <cjwatson@debian.org>

        * man/man1/man.man1 (Controlling formatted output, ENVIRONMENT):
          Explicitly state that -P/$PAGER/$MANPAGER identifies a single
          command with no pipes (Debian bug #363250).

If we want to extend PAGER in general, then I'm willing to revisit this.

Cheers,

-- 
Colin Watson                                       [cjwatson@debian.org]


Reply to: