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

Tollef Fog Heen tfheen at err.no
Sun Jan 2 12:21:50 PST 2011


]] Miklos Vajna 

| On Sun, Jan 02, 2011 at 08:24:02AM +0100, Tollef Fog Heen <tfheen at err.no> wrote:
| > | +	if (!pager)
| > | +		pager = "less";
| > 
| > Doesn't other distributions have sensible-pager(1) or pager(1)?  Also,
| > at least on Debian, less(1) isn't in the base distribution, while
| > more(1) comes from util-linux so is always around.
| 
| Not all distributions have such a command, while all distributions have
| less packaged. What about making it a configure option, but let the
| default be 'less'? Then Debian and other packages can use
| --with-pager=pager or so.

Sounds fine to me.

| > | +	else if (!*pager || !strcmp(pager, "cat"))
| > | +		return;
| > 
| > Why special-casing cat?
| 
| To avoid launching an unnecessary process. 'systemctl | cat' and
| 'systemctl' is the same, except that the in previous case we do not
| launch the pager.

It might be useful to rather just special-case tty output, like ps does,
where piping to a process will not limit the length of the output, so
you can do «ps ax | cat» which then doesn't cut off at $COLUMNS char
rather than special-casing cat.  If people do foo | cat, they should get
what they asked for, IMO.

| > | +	setenv("LESS", "FRSX", 0);
| > 
| > Here you're unconditionally overriding LESS.
| 
| Hm, are you sure about this? setenv(3) writes:
| 
| If name does exist in the environment, then its value is changed to
| value if overwrite is nonzero; if overwrite is zero, then the value of
| name is not changed.

Oh you're right.  I'm not entirely sure what I was thinking. :-)

-- 
Tollef Fog Heen
UNIX is user friendly, it's just picky about who its friends are


More information about the systemd-devel mailing list