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:
parent
9a2f6ab5cf
commit
e60ffeeb20
6
sdn.cpp
6
sdn.cpp
|
@ -879,7 +879,9 @@ fun run_program (initializer_list<const char*> list, const string &filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun view (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) {
|
fun edit (const string &filename) {
|
||||||
|
@ -903,7 +905,7 @@ fun run_pager (FILE *contents) {
|
||||||
dup2 (fileno (contents), STDIN_FILENO);
|
dup2 (fileno (contents), STDIN_FILENO);
|
||||||
|
|
||||||
// Behaviour copies man-db's man(1), similar to POSIX man(1)
|
// 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);
|
if (pager) execl ("/bin/sh", "/bin/sh", "-c", pager, NULL);
|
||||||
_exit (EXIT_FAILURE);
|
_exit (EXIT_FAILURE);
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue