[systemd-devel] [PATCH] systemctl: implement auto-pager a la git

Lennart Poettering lennart at poettering.net
Tue Jan 4 05:06:55 PST 2011


On Tue, 04.01.11 09:29, Tollef Fog Heen (tfheen at err.no) wrote:

> 
> ]] Lennart Poettering 
> 
> | Can you elaborate on the precise semantics of pager(1) and
> | sensible-pager(1)? I found the latter man pages online and hence added
> | this to the things systemctl will now look for by default. But "pager"
> | was a little bit too generic to find anything. 
> 
> pager(1) is the alternative provided by less, more, most, dog, pg and so
> on.
> 
> sensible-pager is a small shell script:
> 
> #!/bin/sh
> 
> ${PAGER:-pager} "$@"
> ret="$?"
> if [ "$ret" -eq 126 ] || [ "$ret" -eq 127 ]; then
> more "$@"
> ret="$?"
> 	if [ "$ret" -eq 126 ] || [ "$ret" -eq 127 ]; then
> 		echo "Couldn't find a pager!" 1>&2
> 		echo "Set the \$PAGER environment variable to your desired pager." 1>&2
> 		exit 1
> 	fi
> fi
> 
> So if you set PAGER in your environment, that'll be preferred, else
> it'll use pager(1), else it'll fall back to more (since that's in
> util-linux, it's guaranteed to be available).

Hmm, so, given that we check PAGER ourselves, calling sensible-pager is
of little benefit for us, right? And I probably should change the
invocation of sensible-pager to pager in my code, so that we search for
"pager", "less" and "more" in this order?

(That shell script sucks btw, it should invoke the pager with 'exec'.)

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list