summaryrefslogtreecommitdiff
path: root/test/integration/test-apt-cli-pager
Commit message (Collapse)AuthorAgeFilesLines
* pager: Also set SMK in LESS, fix LV=C to be LV=-cJulian Andres Klode2025-03-261-1/+1
| | | | | | | | | | | Sync the LESS environment with systemd to make it more user-friendly than just a blinking colon: - S disables the terminal bell - M makes the output verbose, so the prompt is not ":" but "lines 1-n" - K means that Ctrl+c exits the command Also fix the LV= environment variable to use -c and not C.
* Respect custom LESS/MORE/LV variablesJulian Andres Klode2025-03-261-0/+3
| | | | | | Use setenv() to avoid overriding user defined variables. LP: #2103921
* Be more strict about which PAGER to execvp() directlyJulian Andres Klode2024-12-191-0/+11
| | | | | | | | | | | There could be | or ; or other stuff in PAGER that needs special handling, let's encode a list of known-good characters instead. This covers all known pagers. You could also try to execvp() PAGER in its entirety and if it fails with ENOENT fall back to the shell but then you don't get correct error handling if the pager really doesn't exist (in which case we should abort trying to page).
* Introduce automatic pager for read commandsJulian Andres Klode2024-12-181-0/+116
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.