From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 4A/7GfWhoGKMZAEAbAwnHQ (envelope-from ) for ; Wed, 08 Jun 2022 15:19:49 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id YI8FGvWhoGKmPwAA9RJhRA (envelope-from ) for ; Wed, 08 Jun 2022 15:19:49 +0200 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 1241B36180 for ; Wed, 8 Jun 2022 15:19:48 +0200 (CEST) Received: from localhost ([::1]:59062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyvb9-0005Cc-91 for larch@yhetil.org; Wed, 08 Jun 2022 09:19:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyvAN-0004Ou-SU for guix-patches@gnu.org; Wed, 08 Jun 2022 08:52:08 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:48836) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyvAI-0000o2-EC for guix-patches@gnu.org; Wed, 08 Jun 2022 08:52:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nyvAI-0000bW-CT for guix-patches@gnu.org; Wed, 08 Jun 2022 08:52:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55845] [PATCH 0/1] Improve pager selection logic when less is not installed Resent-From: Tobias Geerinckx-Rice Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 08 Jun 2022 12:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55845 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Taiju HIGASHI Cc: 55845@debbugs.gnu.org X-Debbugs-Original-Cc: 55845@debbugs.gnu.org, guix-patches@gnu.org Received: via spool by 55845-submit@debbugs.gnu.org id=B55845.16546926692239 (code B ref 55845); Wed, 08 Jun 2022 12:52:02 +0000 Received: (at 55845) by debbugs.gnu.org; 8 Jun 2022 12:51:09 +0000 Received: from localhost ([127.0.0.1]:42729 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nyv9Q-0000a3-SV for submit@debbugs.gnu.org; Wed, 08 Jun 2022 08:51:09 -0400 Received: from tobias.gr ([80.241.217.52]:54454) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nyv9K-0000ZX-HY for 55845@debbugs.gnu.org; Wed, 08 Jun 2022 08:51:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=2018; bh=y5xvxpwfcyQnp qSsiD7vJzojCjcLVjVF/4XI1ZmIpJE=; h=in-reply-to:date:subject:cc:to: from:references; d=tobias.gr; b=PR4PTgztOUktH2f3oyL2CtuUbRJuqiGAmhTOMJ J63zWbEErvaJuWGDEwJMdY1xEZC4ROPwfFnZHmNJ3lkI81i2dkolejCC9d39NhZvScjbI+ SW7xRQKLmWPgurgRCKDyelIzRhhVeOyseh1kP0uyiZMKQm7AQWURNg6U7UPq+xv63CQlZT 6snEaMdoBpAw0zkJj5aEhLYARSkpZ/lWyT2VEdGBxTCz0didJQqAFmtAbfZaqdvdq01j3/ zivMhrKZNQABtqJtg11P4fhQuJSsaZByHDJ1/jxfy8c5Oenlf+pSaWUAmfHRXo0VsoBiKL zOKal3FzTpHu0Ekq6eD+me8g== Received: by submission.tobias.gr (OpenSMTPD) with ESMTPSA id 81f01fd2 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Wed, 8 Jun 2022 12:50:59 +0000 (UTC) References: <20220608102124.14865-1-higashi@taiju.info> Date: Wed, 08 Jun 2022 14:14:34 +0200 In-reply-to: <20220608102124.14865-1-higashi@taiju.info> BIMI-Selector: v=BIMI1; s=default; Message-ID: <87wndrwc5m@nckx> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" Reply-to: Tobias Geerinckx-Rice X-ACL-Warn: , Tobias Geerinckx-Rice via Guix-patches From: Tobias Geerinckx-Rice via Guix-patches via X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1654694389; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=y5xvxpwfcyQnpqSsiD7vJzojCjcLVjVF/4XI1ZmIpJE=; b=CVE24D6922483YD9xnTapYvh7CBL0WYLqUjv1DgqI1UmCJS+YEJsxLZ+Y9StExhvVo6N5C wUsNDQimgGbBsTcq3p7JyHp+wh4+tICacTRaHnjuJcZN4SfZMo3L8e3EJ+Q0PXzWvsOBqL 4M0yKB8ny/E+K/WYhW8Jpb46HENQrFTxen34/aR8IXiCaShb8Lg5u1nrhy4wHAT4GYNbYb fLWDgmBIjhpCOkZuiURcc7/QYvBM3kpxIKSLfYvB8AaNz/3VpEgIwbbfsKD4iMwzJCqy+J K44rBj336oreesgKDS1cwaxYeiz+cDgQF5epUBahMhP66wJZaNbPazhsH3XCWg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654694389; a=rsa-sha256; cv=none; b=nQ8y8jRiMW8ESAQkjuh2PeMdBivJj2HBeYbJ2u+llo8/rk4GhizNGaDjhyI4XB/ojbgBRR T4+dvfvhqIOFPOc1/fbePtmVmX2cXsJlBc5hKBmfp7w1n6Q5S3eN2AqX7VroE4AqDiro7f zO4mWdHE/6kqGj8JxgOKAmmdMAZrzKc32lsA18mwiGYugHruePORBQKuu7Zj5Y4sspEvq+ 7mREPl9yDM14ncAZDp9gJSvHgQ5/Oj4NlMn0vp72PFuTaFGvzOekwrCDOZ/QNrPIYnD5ZS UIAtKW718R/kPC+6E5yKMTw58oNOCVhQ+qugFTUR3Wg3Bf+lAxwE82VCquu1wA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tobias.gr header.s=2018 header.b=PR4PTgzt; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -6.00 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tobias.gr header.s=2018 header.b=PR4PTgzt; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 1241B36180 X-Spam-Score: -6.00 X-Migadu-Scanner: scn0.migadu.com X-TUID: WK5v386QlQea --=-=-= Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Hi! Taiju HIGASHI =E5=86=99=E9=81=93=EF=BC=9A > The problem rarely occurs, but when we run guix commands in an=20 > environment > where "less" is not installed we get an error. True. Odd that it's gone unreported(?) for so long. > I am concerned about performance degradation due to more=20 > unnecessary > processing. Since you asked=E2=80=A6 :-) One way that this is =E2=80=98expensive=E2=80=99 is that it always calls WH= ICH at=20 least once, no matter what Guix was invoked to do. If you're familiar with Haskell or Nix: Scheme is not that, it's=20 not =E2=80=98lazy=E2=80=99 and will evaluate the (if (which "less") =E2=80= =A6) even when=20 the value is never used. Turning AVAILABLE-PAGER into a procedure=20 would avoid that. Also, you're looking up the final pager in $PATH twice: you call=20 WHICH, but then discard its work by returning the relative string=20 "less". The final OPEN-PIPE* invokes a shell which will search $PATH=20 again. We could save it the trouble by returning an absolute file=20 name: the result of WHICH. And since WHICH returns #f on failure, you can replace the nested=20 IFs with a single OR: (define (available-pager) (or (which "less") (which "more"))) And well, as you probably noticed by now, it's actually more clear=20 and concise if we just in-line what little is left: (let ((pager-command-line (or (getenv "GUIX_PAGER") (getenv "PAGER") (which "less") (which "more") ""))) =E2=80=A6 Your original patch returns #f if no pages could be found. I=20 don't think that is handled, but "" is, so return that instead. Now I think that's 100% equivalent to your original; let me know=20 if I missed a spot. > Also, if you feel that this is a minor issue and not worth=20 > addressing, please > feel free to dismiss it. (Still, a fix to make the error message=20 > more friendly > might be a good idea.) It *is* minor, but then so is the fix, and as written above it=20 doesn't add =E2=80=98overhead=E2=80=99. I think it's a good idea to check = for=20 "more" (but no more) and silently disable paging otherwise. Thanks! T G-R --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iIMEARYKACsWIQT12iAyS4c9C3o4dnINsP+IT1VteQUCYqCbdg0cbWVAdG9iaWFz LmdyAAoJEA2w/4hPVW15J6cA/RQGWhlpt1XXNYCSbQvLTOzELdbnq2yPc9ugwyIP swScAQC4EhfrTujG0/3PIR1Igbvklb7ThJ8dxIzw1rEC9SyFAw== =+rk9 -----END PGP SIGNATURE----- --=-=-=--