diff options
| author | Julian Andres Klode <jak@debian.org> | 2024-12-16 17:05:40 +0100 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2024-12-18 10:25:24 +0100 |
| commit | 6e260e26e4cd671f781151e24d89a17b29a55530 (patch) | |
| tree | 0ae3b4f9122e5168df4d4d09102a88196d6baaf2 /doc | |
| parent | 19000fab15ab0b30c95a1bf6e034aa3c6bdc36cb (diff) | |
Introduce automatic pager for read commands
Automatically show the output of `show`, `policy`, `list`,
`search`, `showsrc` in a pager.
The pager setup is inspired by git's pager setup. Notably,
the pager is found using APT_PAGER and PAGER variables.
We wait for the pager to be setup somewhat correctly by
using a notify pipe to figure out whether execvp() was
succesful - then the pipe will read EOF as the other end
got closed by CLOEXEC during exec - or not, then the pipe
will contain an errno.
We set up the correct handlers for signals and exit to close
the fds and wait for the pager. Notably inside the signal
handler we cannot flush our streams, only close them, so
there is some duplication.
We call the InitOutputPager() function from inside the
various Do...() functions rather than setting it up
generally in InitOutput(). Doing so allows us to first
render the progress without a pager, and then setup
the pager for the content only which improves user
experience.
When we setup a pager we also take care to disable
standard input, as we should not be prompting users
while a pager is running (the pager will be reading
from the tty directly). We do this by dup2-ing() a
/dev/null over it; if we just close()d the fd, another
open() might reuse the fd number and problems could
occur.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/examples/configure-index | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/doc/examples/configure-index b/doc/examples/configure-index index 9623514b8..15338c17d 100644 --- a/doc/examples/configure-index +++ b/doc/examples/configure-index @@ -696,6 +696,7 @@ acquire::*::by-hash "<STRING>"; // Unsorted options: Some of those are used only internally +pager "<BOOL>"; // true if a pager is to be used help "<BOOL>"; // true if the help message was requested via e.g. --help version "<BOOL>"; // true if the version number was requested via e.g. --version Binary "<STRING>"; // name of the program run like apt-get, apt-cache, … |
