diff mbox series

[bug#44663] ui: Launch $PAGER through the shell.

Message ID 20201115184726.29944-1-me@tobias.gr
State Accepted
Headers show
Series [bug#44663] ui: Launch $PAGER through the shell. | expand

Checks

Context Check Description
cbaines/submitting builds success
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job

Commit Message

Tobias Geerinckx-Rice Nov. 15, 2020, 6:47 p.m. UTC
This is the convention elsewhere and sounds like the right thing to do.

* guix/ui.scm (call-with-paginated-output-port): Substitute OPEN-PIPE
for OPEN-PIPE*.

Reported by Daniel Brooks <db48x@db48x.net>.
---
 guix/ui.scm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Ludovic Courtès Nov. 15, 2020, 8:46 p.m. UTC | #1
Hi,

Tobias Geerinckx-Rice <me@tobias.gr> skribis:

> This is the convention elsewhere and sounds like the right thing to do.
>
> * guix/ui.scm (call-with-paginated-output-port): Substitute OPEN-PIPE
> for OPEN-PIPE*.
>
> Reported by Daniel Brooks <db48x@db48x.net>.

What’s the rationale though?  Are there cases where this makes a
practical difference?

I’m all for avoiding the shell if there’s no need for it.

Thanks,
Ludo’.
Daniel Brooks Nov. 15, 2020, 9:38 p.m. UTC | #2
Ludovic Courtès <ludo@gnu.org> writes:

> What’s the rationale though?  Are there cases where this makes a
> practical difference?

The error I hit was effectively running PAGER=less -FXRS guix search
foo. Everything else that uses PAGER handles this case just fine.

db48x
Ludovic Courtès Nov. 16, 2020, 8:16 a.m. UTC | #3
Daniel Brooks <db48x@db48x.net> skribis:

> Ludovic Courtès <ludo@gnu.org> writes:
>
>> What’s the rationale though?  Are there cases where this makes a
>> practical difference?
>
> The error I hit was effectively running PAGER=less -FXRS guix search
> foo. Everything else that uses PAGER handles this case just fine.

Oh, I see, hmm.  I feel that going through the shell makes things more
brittle, but you describe a valid use case, so maybe we should just go
ahead and apply the patch Tobias posted.

Ludo’.
Tobias Geerinckx-Rice Nov. 29, 2020, 4:52 p.m. UTC | #4
> I feel that going through the shell makes things more brittle

I don't think it's brittle but it's icky.  Using OPEN-PIPE is just 
the easiest way to get the shell to do free parsing for us.  It 
also allows using pipes and for-loops in PAGER so I agree it's not 
ideal.

Here's a v2 that does more work for less result, but feels less 
dirty :-)

Kind regards,

T G-R
diff mbox series

Patch

diff --git a/guix/ui.scm b/guix/ui.scm
index 4e686297e8..2b7d9dd64b 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -72,7 +72,7 @@ 
   #:use-module (ice-9 match)
   #:use-module (ice-9 format)
   #:use-module (ice-9 regex)
-  #:autoload   (ice-9 popen) (open-pipe* close-pipe)
+  #:autoload   (ice-9 popen) (open-pipe close-pipe)
   #:autoload   (system base compile) (compile-file)
   #:autoload   (system repl repl)  (start-repl)
   #:autoload   (system repl debug) (make-debug stack->vector)
@@ -1673,9 +1673,9 @@  zero means that PACKAGE does not match any of REGEXPS."
       ;; 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* OPEN_WRITE
-                                 (or (getenv "GUIX_PAGER") (getenv "PAGER")
-                                     "less")))))
+                     (open-pipe (or (getenv "GUIX_PAGER") (getenv "PAGER")
+                                    "less")
+                                OPEN_WRITE))))
         (dynamic-wind
           (const #t)
           (lambda () (proc pager))