Subject: [PATCH 1/1] ui: Improve pager selection logic when less is not installed.

From: Taiju HIGASHI <[email-masked]>
Date: Wed, 8 Jun 2022 19:22:57 +0900

* guix/ui.scm (available-pager): New variable. Holds available pagers.
  (call-with-paginated-output-port): Get an alternative program from the
  available-pager variable when the environment variable is not set.
---
 guix/ui.scm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index cb68a07c6c..22169a7eb8 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2020 Arun Isaac <[email-masked]>
 ;;; Copyright © 2020 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2018 Steve Sprang <[email-masked]>
+;;; Copyright © 2022 Taiju HIGASHI <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1672,11 +1673,18 @@ (define* (pager-wrapped-port #:optional (port (current-output-port)))
     (_
      #f)))
 
+(define available-pager
+  (if (which "less")
+      "less"
+      (if (which "more")
+          "more"
+          #f)))
+
 (define* (call-with-paginated-output-port proc
                                           #:key (less-options "FrX"))
   (let ((pager-command-line (or (getenv "GUIX_PAGER")
                                 (getenv "PAGER")
-                                "less")))
+                                available-pager)))
     ;; Setting PAGER to the empty string conventionally disables paging.
     (if (and (not (string-null? pager-command-line))
              (isatty?* (current-output-port)))
-- 
2.36.1