From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id sLAzAgikoGIO9gAAbAwnHQ (envelope-from ) for ; Wed, 08 Jun 2022 15:28:40 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 6BXxAQikoGIfTgEAauVa8A (envelope-from ) for ; Wed, 08 Jun 2022 15:28:40 +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 896662C64E for ; Wed, 8 Jun 2022 15:28:39 +0200 (CEST) Received: from localhost ([::1]:45956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyvji-0007oS-MF for larch@yhetil.org; Wed, 08 Jun 2022 09:28:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyvUd-0006e3-5I for guix-patches@gnu.org; Wed, 08 Jun 2022 09:13:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:48864) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyvUc-0005Gr-Qu for guix-patches@gnu.org; Wed, 08 Jun 2022 09:13:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nyvUc-000178-Ks for guix-patches@gnu.org; Wed, 08 Jun 2022 09:13: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: Taiju HIGASHI Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 08 Jun 2022 13:13: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: Tobias Geerinckx-Rice 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.16546939774258 (code B ref 55845); Wed, 08 Jun 2022 13:13:02 +0000 Received: (at 55845) by debbugs.gnu.org; 8 Jun 2022 13:12:57 +0000 Received: from localhost ([127.0.0.1]:42759 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nyvUX-00016b-B2 for submit@debbugs.gnu.org; Wed, 08 Jun 2022 09:12:57 -0400 Received: from mail-pg1-f170.google.com ([209.85.215.170]:44836) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nyvUT-000168-FC for 55845@debbugs.gnu.org; Wed, 08 Jun 2022 09:12:54 -0400 Received: by mail-pg1-f170.google.com with SMTP id c18so10526720pgh.11 for <55845@debbugs.gnu.org>; Wed, 08 Jun 2022 06:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=taiju-info.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=U43AoQ11OKCiq3jnwo+i9sNrKzfDKJ6lwhY6HEHWoFY=; b=7TD88WnpqO7bwiC58PNa/L2gMjJvPWPPQlOoUxOj/COdXdlb/e5PIQx+ep8TXoJEpL fKN94SPaPk6jptgfnq/jA1zIdHROk+BpcO3mRWpgFSn1pl+VluSz/zoZCj++09YK3zS8 EQXXqTzTA8WwKpdmnY4O67iGXba/yPa0QaZPcBEUcyzi/yvZcf5Je5L892kYNzoQoWQ9 YyyiuuOjmj+0WQD0IR335DC1SZnQFNvenK8UDTNZMMXzGqDn1Lo9ZOojCP2ayAK2WJRF HA3MTG3WjtKt4BFbXoH5ATosYpRiAItJiVqNmo8AJWIhDGM49NNFOWk/oxmw2tC0Mps4 So1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=U43AoQ11OKCiq3jnwo+i9sNrKzfDKJ6lwhY6HEHWoFY=; b=C3JfxoX0caUFM3RcNLwq43kFDypeXG+YT9MG+QPDoP35PyNkvJfQ5z9SVxyLMXpC9I /YeMtCODgMpHbRaXdNsuDyBFyAu6n5D5R/WNlfVenOUdqJ0igE/UXY+3fB0bbZCANXiN zhzCNwzEckxPvRLYtsN7RuVkV7wmhV44tgY/dOSEFMkYdXuuDTJEudNhEDj28qzazjT6 1Fq8e9prSK2RV9GzE+n88XZ1BiNI0H75W9ZKOG1DEYQF4QwJBKXGSPlnUqXK4IwFFUTN m6Kub5piN+3u8uSCkeOFTUA6tDgWkzoN9jXNrwtCG7QJ2ZiAM6uNphEq1D01ilKavCfB 6Sfw== X-Gm-Message-State: AOAM530UwmMgTCRN3ZXxnTGotHDAHJp4MkVCaQzOr5MHxLdNh01xA8p3 mt5QbAzLW/pojDAd5pc4efezmQ== X-Google-Smtp-Source: ABdhPJxWquvY7zwnl3SApFee8YE+bAL9n3mv5dVxnIGV1U2t5hMalGKkWSfk8SQbKHP2TDzYJR9tWg== X-Received: by 2002:a63:189:0:b0:3fa:ab5:4218 with SMTP id 131-20020a630189000000b003fa0ab54218mr29574537pgb.91.1654693967490; Wed, 08 Jun 2022 06:12:47 -0700 (PDT) Received: from Taix ([240b:253:ec40:2400:b7d1:436e:2d61:e925]) by smtp.gmail.com with ESMTPSA id f13-20020a63dc4d000000b003fdb58d951dsm6792186pgj.42.2022.06.08.06.12.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 06:12:37 -0700 (PDT) From: Taiju HIGASHI References: <20220608102124.14865-1-higashi@taiju.info> <87wndrwc5m@nckx> Date: Wed, 08 Jun 2022 22:12:34 +0900 In-Reply-To: <87wndrwc5m@nckx> (Tobias Geerinckx-Rice's message of "Wed, 08 Jun 2022 14:14:34 +0200") Message-ID: <8735gf47ul.fsf@taiju.info> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-2022-jp 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" 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=1654694919; h=from:from:sender:sender: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=U43AoQ11OKCiq3jnwo+i9sNrKzfDKJ6lwhY6HEHWoFY=; b=GLFdl7H4Fm1ufSyDoENmkh5dAEh1TFtJjyXu5Bp1K2s/MlWiw8L6m9b+56thj3QlGppq7+ gdlw0UmOgZzl7PU2iVxjTpAo0Aov9t38tP/oENbgSe4E0S6v5A1IMVDru6iLGnhpSArsfa IOh5pC64ckuUYHldhjRlewb3kooBRREAN86kZwBF2qKj8ehLWEAjVVPWbDu2jH5ftVyD9m 5AUdKNPwhhOUjeEBMhvGd89YKRDTThVavuNGwNmJ++B2+9QZV428mRF6+/BsjswJNjIjHb IvZKAkOPfYbQXmSypc5jggfo04LDm8brKXQOLsvL9UUcDZj4KxYaYhWeBVCPvA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654694919; a=rsa-sha256; cv=none; b=b7OYXp/ZOmGWvpcNfq95WpkgRylDxAcudqpgFwdM+SrkFrwuA5pLvww8d4dH8SGamSTXQm g/Oz3GeHkzQlXH16hT4jvGykX+V1bw/BWUptbWfHHNcMNDp8mqlczA7ZzTD1ZPhunXdLtt s3qWibnnoRAlUYNwzg1P+cxfyPip0KkoBL2hd+s4C2nVzTu/al3uF7+SlylksEGWLL5TPX 8oc6RJkmRl6ETLFvOS8L3iPW5m3/A5/PpACT17XLR4q0UY4AWp3L01a5lynuiKqVfgQ+Fh oSoageMKwxo5oKwB4Nxhztc8M3zO9SKmYdpSM0ou/RdoaO49uF6QXtu8Xqrf2g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=taiju-info.20210112.gappssmtp.com header.s=20210112 header.b=7TD88Wnp; dmarc=none; 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: 1.00 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=taiju-info.20210112.gappssmtp.com header.s=20210112 header.b=7TD88Wnp; dmarc=none; 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: 896662C64E X-Spam-Score: 1.00 X-Migadu-Scanner: scn1.migadu.com X-TUID: uG0w6HZBhk4c Hi 写道, Thank you for reviwing! > Hi! > > Taiju HIGASHI 写道: >> The problem rarely occurs, but when we run guix commands in an >> 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 unnecessary >> processing. > > Since you asked… :-) > > One way that this is ‘expensive’ is that it always calls WHICH at > least once, no matter what Guix was invoked to do. > > If you're familiar with Haskell or Nix: Scheme is not that, it's not > ‘lazy’ and will evaluate the (if (which "less") …) even when the > value is never used. Turning AVAILABLE-PAGER into a procedure would > avoid that. I understand that I can delay the evaluation timing if I make it a procedure, but is my understanding correct that the number of calls will remain the same because it will be evaluated each time the `call-with-paginated-output-port` procedure is called? I agree with your point that it would be better to make it a procedure, as it would be more eco-friendly to not have to evaluate when GUIX_PAGER or PAGER is specified. > Also, you're looking up the final pager in $PATH twice: you call > WHICH, but then discard its work by returning the relative string > "less". > > The final OPEN-PIPE* invokes a shell which will search $PATH again. > We could save it the trouble by returning an absolute file name: the > result of WHICH. I see, I did not understand that behavior. Thank you. > And since WHICH returns #f on failure, you can replace the nested IFs > with a single OR: > > (define (available-pager) > (or (which "less") > (which "more"))) This one is also more readable. Thank you. > And well, as you probably noticed by now, it's actually more clear 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") > ""))) > … You mean that the $PATH lookup in open-pipe can be suppressed? Also, I misunderstood the string-null? spec; available-pager should have returned an empty string. > Your original patch returns #f if no pages could be found. I 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 if I > missed a spot. I thought what you said was completely correct. >> Also, if you feel that this is a minor issue and not worth >> addressing, please >> feel free to dismiss it. (Still, a fix to make the error message >> more friendly >> might be a good idea.) > > It *is* minor, but then so is the fix, and as written above it doesn't > add ‘overhead’. I think it's a good idea to check for "more" (but > no more) and silently disable paging otherwise. I will just write what you have told me, but may I continue to modify the patch? Thank, -- Taiju