From patchwork Sun Nov 15 19:46:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Geerinckx-Rice X-Patchwork-Id: 25146 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id D13FE27BBF5; Sun, 15 Nov 2020 19:51:39 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 15A3C27BBF4 for ; Sun, 15 Nov 2020 19:51:39 +0000 (GMT) Received: from localhost ([::1]:33596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keO3m-0002Jj-96 for patchwork@mira.cbaines.net; Sun, 15 Nov 2020 14:51:38 -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 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Tobias Geerinckx-Rice , Tobias Geerinckx-Rice via Guix-patches X-Patchwork-Original-From: Tobias Geerinckx-Rice via Guix-patches via From: Tobias Geerinckx-Rice X-getmail-retrieved-from-mailbox: Patches Guix, Tobias Geerinckx-Rice via Guix-patches via 写道: > This is the convention elsewhere and sounds like the right thing > to do. Before this patch, using PAGER= failed: $ PAGER= guix search e In execvp of : No such file or directory $ With it, it fails in a slightly worse way: $ PAGER= guix search e $ # nothing, because we spawn the shell that swallows all Attached are two possible solutions. One falls back to ‘less’, the other to no paging. I think I prefer the former (‘Ignore empty $PAGER variables’) because the concept of ‘unset but empty’ could confuse ‘users’. Is that too patronising? Do tell. Kind regards, T G-R From e1cf7e852c4a4c0cfce8c0de5625d026229dd71b 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 $PAGER is "". --- 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 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -1663,24 +1663,27 @@ zero means that PACKAGE does not match any of REGEXPS." (define* (call-with-paginated-output-port proc #:key (less-options "FrX")) - (if (isatty?* (current-output-port)) - ;; Set 'LESS' so that 'less' exits if everything fits on the screen (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', use 'R' - ;; 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)) - (open-pipe (or (getenv "GUIX_PAGER") (getenv "PAGER") - "less") - OPEN_WRITE)))) - (dynamic-wind - (const #t) - (lambda () (proc pager)) - (lambda () (close-pipe pager)))) - (proc (current-output-port)))) + (let ((command (or (getenv "GUIX_PAGER") (getenv "PAGER") + "less"))) + ;; If a user types ‘PAGER= guix foo’ their intention is probably to disable + ;; paging entirely, not to use Guix's default pager. + (if (and (not (string=? "" command)) + (isatty?* (current-output-port))) + ;; Set 'LESS' so that 'less' exits if everything fits on the screen (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', use 'R' + ;; 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)) + (open-pipe command OPEN_WRITE)))) + (dynamic-wind + (const #t) + (lambda () (proc pager)) + (lambda () (close-pipe pager)))) + (proc (current-output-port))))) (define-syntax with-paginated-output-port (syntax-rules () -- 2.29.2