From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id +D9YEM2GsV9GFQAA0tVLHw (envelope-from ) for ; Sun, 15 Nov 2020 19:51:41 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id MIcyDM2GsV8GFgAAbx9fmQ (envelope-from ) for ; Sun, 15 Nov 2020 19:51:41 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 863659401D0 for ; Sun, 15 Nov 2020 19:51:40 +0000 (UTC) Received: from localhost ([::1]:33596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keO3n-0002Jj-2x for larch@yhetil.org; Sun, 15 Nov 2020 14:51:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keNzL-0007yK-TD for guix-patches@gnu.org; Sun, 15 Nov 2020 14:47:05 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:42675) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1keNzK-0008Eo-7K for guix-patches@gnu.org; Sun, 15 Nov 2020 14:47:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1keNzK-0003k4-5t for guix-patches@gnu.org; Sun, 15 Nov 2020 14:47:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#44663] [PATCH] ui: Launch $PAGER through the shell. Resent-From: Tobias Geerinckx-Rice Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 15 Nov 2020 19:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44663 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 44663@debbugs.gnu.org Received: via spool by 44663-submit@debbugs.gnu.org id=B44663.160546961614371 (code B ref 44663); Sun, 15 Nov 2020 19:47:02 +0000 Received: (at 44663) by debbugs.gnu.org; 15 Nov 2020 19:46:56 +0000 Received: from localhost ([127.0.0.1]:54221 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1keNzD-0003jj-P9 for submit@debbugs.gnu.org; Sun, 15 Nov 2020 14:46:56 -0500 Received: from tobias.gr ([80.241.217.52]:40924) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1keNz9-0003jY-9G for 44663@debbugs.gnu.org; Sun, 15 Nov 2020 14:46:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobias.gr; s=2018; bh=88OgwbgYRUfP8pFekmlImPhJleIDKzC3RRAFGTEUkF8=; h=date:in-reply-to: references:subject:to:from; b=g0nI1OvRh+kz8w7ARKL2YOAQlE+Zkm35dhtrLGHX 30D8vA9h6Gv1shHN7d2/Y1NEJz8eiPJFQLm0+G6022dyav0h7zuyZ4beiiozno+Y9w5xzB gLD3Xmn6Bh2EaEzy3v0LeqIst4S8xVqLlOJvXKjYAhqcqLBUsC45yiqrcAytD6Tb7M3OQ6 S8miZ2ySsgGwi6g6qHjqtRijJxgx0cVZx6CLz7GB237SoyBH6WZxVT2MUN28OblSvZd5cc RBvRc3c9p6PyVHGRcfRyuvNt2o1GJJgW5+JOkuSuQXxMN3GoJRcefSc6Uo9ophi4cNj3BM Dia5/Gdbtr6jhK3QrqDjbA== Received: by submission.tobias.gr (OpenSMTPD) with ESMTPSA id 97815745 (TLSv1.2:ECDHE-ECDSA-AES256-GCM-SHA384:256:NO) for <44663@debbugs.gnu.org>; Sun, 15 Nov 2020 19:46:54 +0000 (UTC) BIMI-Selector: v=BIMI1; s=default; References: <20201115184726.29944-1-me@tobias.gr> In-reply-to: <20201115184726.29944-1-me@tobias.gr> Date: Sun, 15 Nov 2020 20:46:47 +0100 Message-ID: <878sb2xv14.fsf@nckx> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" Reply-to: Tobias Geerinckx-Rice , Tobias Geerinckx-Rice via Guix-patches From: Tobias Geerinckx-Rice via Guix-patches via X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=fail (headers rsa verify failed) header.d=tobias.gr header.s=2018 header.b=g0nI1OvR; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -2.11 X-TUID: lrDqAOYMtpAQ --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Guix, Tobias Geerinckx-Rice via Guix-patches via =E5=86=99=E9=81=93=EF=BC=9A > This is the convention elsewhere and sounds like the right thing=20 > to do. Before this patch, using PAGER=3D failed: $ PAGER=3D guix search e In execvp of : No such file or directory $ With it, it fails in a slightly worse way: $ PAGER=3D guix search e $ # nothing, because we spawn the shell that swallows all Attached are two possible solutions. One falls back to =E2=80=98less=E2=80= =99,=20 the other to no paging. I think I prefer the former (=E2=80=98Ignore empty $PAGER variables=E2=80= =99)=20 because the concept of =E2=80=98unset but empty=E2=80=99 could confuse =E2= =80=98users=E2=80=99.=20 Is that too patronising? Do tell. Kind regards, T G-R --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ui-Ignore-empty-PAGER-variables.patch Content-Transfer-Encoding: quoted-printable From=20dc64aadd9b124df37fcdf2f6dc057b61cf05a473 Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Sun, 15 Nov 2020 20:36:32 +0100 Subject: [PATCH] ui: Ignore empty $PAGER variables. * guix/ui.scm (call-with-paginated-output-port): Treat "" as unset. =2D-- guix/ui.scm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/guix/ui.scm b/guix/ui.scm index 66614eef7c..584afc65dd 100644 =2D-- a/guix/ui.scm +++ b/guix/ui.scm @@ -1673,8 +1673,11 @@ zero means that PACKAGE does not match any of REGEXP= S." ;; instead of 'r': this strips hyperlinks but allows 'less' to make a ;; good estimate of the line length. (let ((pager (with-environment-variables `(("LESS" ,less-options)) =2D (open-pipe (or (getenv "GUIX_PAGER") (getenv "PAGER= ") =2D "less") + ;; Ignore environment variables set to "" as if unset. + (open-pipe (find (lambda (s) (and s (not (string=3D? = "" s)))) + (list (getenv "GUIX_PAGER") + (getenv "PAGER") + "less")) OPEN_WRITE)))) (dynamic-wind (const #t) =2D-=20 2.29.2 --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-ui-Disable-paging-if-PAGER-is-set-to-the-empty-strin.patch Content-Transfer-Encoding: quoted-printable From=20e1cf7e852c4a4c0cfce8c0de5625d026229dd71b Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Sun, 15 Nov 2020 20:26:54 +0100 Subject: [PATCH] ui: Disable paging if $PAGER is set to the empty string. * guix/ui.scm (call-with-paginated-output-port): Don't open a pipe if $PAGE= R is "". =2D-- guix/ui.scm | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/guix/ui.scm b/guix/ui.scm index 66614eef7c..bb03e06759 100644 =2D-- a/guix/ui.scm +++ b/guix/ui.scm @@ -1663,24 +1663,27 @@ zero means that PACKAGE does not match any of REGEX= PS." =20 (define* (call-with-paginated-output-port proc #:key (less-options "FrX")) =2D (if (isatty?* (current-output-port)) =2D ;; Set 'LESS' so that 'less' exits if everything fits on the scree= n (F), =2D ;; lets ANSI escapes through (r), does not send the termcap =2D ;; initialization string (X). Set it unconditionally because some =2D ;; distros set it to something that doesn't work here. =2D ;; =2D ;; For things that produce long lines, such as 'guix processes', u= se 'R' =2D ;; instead of 'r': this strips hyperlinks but allows 'less' to mak= e a =2D ;; good estimate of the line length. =2D (let ((pager (with-environment-variables `(("LESS" ,less-options)) =2D (open-pipe (or (getenv "GUIX_PAGER") (getenv "PAGER= ") =2D "less") =2D OPEN_WRITE)))) =2D (dynamic-wind =2D (const #t) =2D (lambda () (proc pager)) =2D (lambda () (close-pipe pager)))) =2D (proc (current-output-port)))) + (let ((command (or (getenv "GUIX_PAGER") (getenv "PAGER") + "less"))) + ;; If a user types =E2=80=98PAGER=3D guix foo=E2=80=99 their intention= is probably to disable + ;; paging entirely, not to use Guix's default pager. + (if (and (not (string=3D? "" command)) + (isatty?* (current-output-port))) + ;; Set 'LESS' so that 'less' exits if everything fits on the scree= n (F), + ;; lets ANSI escapes through (r), does not send the termcap + ;; initialization string (X). Set it unconditionally because some + ;; distros set it to something that doesn't work here. + ;; + ;; For things that produce long lines, such as 'guix processes', u= se 'R' + ;; instead of 'r': this strips hyperlinks but allows 'less' to mak= e a + ;; good estimate of the line length. + (let ((pager (with-environment-variables `(("LESS" ,less-options)) + (open-pipe command OPEN_WRITE)))) + (dynamic-wind + (const #t) + (lambda () (proc pager)) + (lambda () (close-pipe pager)))) + (proc (current-output-port))))) =20 (define-syntax with-paginated-output-port (syntax-rules () =2D-=20 2.29.2 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iIMEARYKACsWIQT12iAyS4c9C3o4dnINsP+IT1VteQUCX7GFpw0cbWVAdG9iaWFz LmdyAAoJEA2w/4hPVW15JZgBALaG1REpJTNylqtJt31+NVRwVhOBIXMJp1jmbq4G qgHZAP0fbctqYofXfp5Sg2ctS7kJmuPmRyY90XfHpxXotDY6Dw== =6BJg -----END PGP SIGNATURE----- --==-=-=--