Improve PAGER defaults

We basically need less(1), nothing else will work correctly.

I'm not sure where I took pager(1) from, might be a Debian thing.
This commit is contained in:
Přemysl Eric Janouch 2020-09-28 21:34:09 +02:00
parent 9a2f6ab5cf
commit e60ffeeb20
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 4 additions and 2 deletions

View File

@ -879,7 +879,9 @@ fun run_program (initializer_list<const char*> list, const string &filename) {
}
fun view (const string &filename) {
run_program ({(const char *) getenv ("PAGER"), "pager", "cat"}, filename);
// XXX: we cannot realistically detect that the pager hasn't made a pause
// at the end of the file, so we can't ensure all contents have been seen
run_program ({(const char *) getenv ("PAGER"), "less", "cat"}, filename);
}
fun edit (const string &filename) {
@ -903,7 +905,7 @@ fun run_pager (FILE *contents) {
dup2 (fileno (contents), STDIN_FILENO);
// Behaviour copies man-db's man(1), similar to POSIX man(1)
for (auto pager : {(const char *) getenv ("PAGER"), "pager", "cat"})
for (auto pager : {(const char *) getenv ("PAGER"), "less", "cat"})
if (pager) execl ("/bin/sh", "/bin/sh", "-c", pager, NULL);
_exit (EXIT_FAILURE);
default: