darcs

Patch 2269 do not use a pager when $DARCS_PAGER // $PAGER is set ...

Title do not use a pager when $DARCS_PAGER // $PAGER is set ...
Superseder Nosy List gpiero
Related Issues
Status accepted Assigned To
Milestone

Created on 2022-12-16.10:20:36 by gpiero, last changed 2023-06-24.16:27:58 by ganesh.

Files
File name Status Uploaded Type Edit Remove
do-not-use-a-pager-when-_darcs_pager-__-_pager-is-set-to-the-empty-string.dpatch dead gpiero, 2022-12-16.10:20:34 application/x-darcs-patch
do-not-use-a-pager-when-_darcs_pager-__-_pager-is-set-to-the-empty-string.dpatch gpiero, 2022-12-16.10:44:44 text/plain
patch-preview.txt gpiero, 2022-12-16.10:20:34 text/x-darcs-patch
See mailing list archives for discussion on individual patches.
Messages
msg23049 (view) Author: gpiero Date: 2022-12-16.10:20:34
I was trying to visualize a (longer than 20 lines) whatsnew without invoking a
pager and naively typed:

$ PAGER= darcs w
Rebase in progress: 1 suspended patch
This is a bug! Please report it at http://bugs.darcs.net or via email to bugs@darcs.net:
impossible
CallStack (from HasCallStack):
  error, called at src/Darcs/UI/External.hs:398:29 in darcs-2.17.2-inplace:Darcs.UI.External

Sure, I could run `darcs w | cat` but why not (ab)use the envvars and avoid a
fork?

1 patch for repository http://darcs.net/screened:

patch 217bc7902ce6c89ed26cbd69bcb27dcb5bf95e62
Author: Gian Piero Carrubba <gpiero@rm-rf.it>
Date:   Fri Dec 16 10:56:35 CET 2022
  * do not use a pager when $DARCS_PAGER // $PAGER is set to the empty string
Attachments
msg23050 (view) Author: gpiero Date: 2022-12-16.10:44:45
Amended patch because of a typo in the help description.
Attachments
msg23064 (view) Author: ganesh Date: 2022-12-31.13:29:24
I had a quick Google for whether `PAGER` is already specified anywhere 
and found https://unix.stackexchange.com/a/213369/1057

"If the PAGER variable is null or not set, the command shall be either 
more or  another  paginator  utility documented in the system 
documentation."

However actually experimenting with man on Ubuntu, I get this behaviour:

 - PAGER not set: uses /usr/bin/pager -> /etc/alternatives/pager -> 
/usr/bin/less
 - PAGER is set to the empty string (is that the same as null?): doesn't 
use a pager

So I think your patch is actually consistent with man and makes sense. 
Maybe it should have a test?
msg23067 (view) Author: gpiero Date: 2022-12-31.16:01:17
* [Sat, Dec 31, 2022 at 01:29:24PM +0000] Ganesh Sittampalam:
>Maybe it should have a test?

The fact is I don't know how to safely test it: if it fails it would 
invoke a pager and block the tests run waiting for an input from the 
user. Suboptimal for CI and not great for manual invocations either.
msg23069 (view) Author: ganesh Date: 2022-12-31.22:32:30
Fair enough, it doesn't look like there are any other tests of that 
variable anyway (which isn't a great justification in itself but it does 
back up your view that it's not easy.)
msg23085 (view) Author: gpiero Date: 2023-01-30.18:05:21
* [Sat, Dec 31, 2022 at 01:29:24PM +0000] Ganesh Sittampalam:
>I had a quick Google for whether `PAGER` is already specified anywhere
>and found https://unix.stackexchange.com/a/213369/1057
>
>"If the PAGER variable is null or not set, the command shall be either
>more or  another  paginator  utility documented in the system
>documentation."

The same wording is used in POSIX/SUS: 
http://pubs.opengroup.org/onlinepubs/9699919799

>However actually experimenting with man on Ubuntu, I get this 
>behaviour:
[...]
> - PAGER is set to the empty string (is that the same as null?): 
> doesn't use a pager

There appears to be some variance here. On FreeBSD

$ MANPAGER= PAGER= man 1 man

still invokes `less -s` (as documented in its own manpage). Actually, 
given that GNU man (as shipped on Debian) contradicts SUSv4 (and its own 
documentation), I would consider that to be a bug. Anyway, even without 
discussing about the descriptive/prescriptive dualism of POSIX/SUS, my 
2c opinion is that that behaviour only applies to the man utility and 
other programs are not required to act the same.

>Maybe it should have a test?

As it turned out, the test framework capturing the output means that 
isTerminal is always False in tests, so any pager-related test is 
fundamentally useless.
History
Date User Action Args
2022-12-16 10:20:36gpierocreate
2022-12-16 10:44:46gpierosetfiles: + do-not-use-a-pager-when-_darcs_pager-__-_pager-is-set-to-the-empty-string.dpatch
messages: + msg23050
2022-12-31 13:29:24ganeshsetstatus: needs-screening -> review-in-progress
messages: + msg23064
2022-12-31 16:01:18gpierosetmessages: + msg23067
2022-12-31 22:32:31ganeshsetstatus: review-in-progress -> accepted-pending-tests
messages: + msg23069
2023-01-30 18:05:25gpierosetmessages: + msg23085
2023-06-24 16:27:58ganeshsetstatus: accepted-pending-tests -> accepted