Hi,

Guillem Jover wrote:

> So, first, thanks for the constructive proposals! But I'd rather not
> revert this change. I'm happy to implement anything sane people might
> find useful to cope with such change. This includes the following
> changes which I've started coding:
>
>   * DPKG_PAGER (equivalent to PAGER, so it will accept arguments).
>   * Set LESS (if unset) to something along the lines of -FRSXMQ, which
>     sould fix the clear-screen-problem, the ugly-output, and
>     blocking-on-pager-when-unnecessary.
>   * New --no-pager option (that can be set in the config file, for
>     dpkg, although dpkq-query does not currently honor any config,
>     but I might need to implement something for the path mapping
>     options anyway in the future).

In case it helps, here's some relevant details from Git:

At build time:

 # Define DEFAULT_PAGER to a sensible pager command (defaults to "less") if
 # you want to use something different.  The value will be interpreted by the
 # shell at runtime when it is used.

 # Define PAGER_ENV to a SP separated VAR=VAL pairs to define
 # default environment variables to be passed when a pager is spawned, e.g.
 #
 #    PAGER_ENV = LESS=FRX LV=-c
 #
 # to say "export LESS=FRX (and LV=-c) if the environment variable
 # LESS (and LV) is not set, respectively".

PAGER_ENV defaults to LESS=FRX LV=-c.

FreeBSD has 'PAGER_ENV = LESS=FRX LV=-c MORE=FRX' and AIX has
'DEFAULT_PAGER = more'.

At run time:

- low-level (plumbing) commands don't launch a pager

- the main benefit of pagination is in commands like "git log" that
  produce incremental output, since it allows the user to benefit from
  output earlier

- the git driver command supports -p/--paginate and -P/--no-pager

- GIT_PAGER=cat is a special case.  It doesn't actually pipe into
  "cat" but just doesn't launch a pager.

- documentation encourages using settings like GIT_PAGER="less -S" or
  GIT_PAGER="less -+F" to selectively override the FRX default settings.

- pagination keys off of whether standard output is a terminal.  There's
  also a GIT_PAGER_IN_USE envvar that can be used when standard output
  is *not* a terminal to turn on certain features that normally require
  a terminal (like color)

- configuration allows turning on or off pagination on a per-subcommand
  basis

- pagination configuration has been an attack vector in the past

- "git var GIT_PAGER" prints a shell-ready command, for scripted use

- Git is the parent process and the pager is the child.  atexit (and
  on signal), we signal EOF to the pager and wait() for it.

  In olden days, we ran the pager as the parent process instead of the
  child.  That didn't work on Windows and was painful in some other
  ways, too.

- We used to use execvp() to handle some commands, but this interacted
  poorly with pager handling.  Nowadays we use fork/exec followed by
  wait() instead, which is important for that atexit and signal
  handling code.

Thanks and ohpe that helps,
Jonathan

Reply via email to