summary refs log tree commit diff
path: root/guix/inferior.scm
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-10-02 19:12:38 +0100
committerChristopher Baines <mail@cbaines.net>2019-10-15 19:01:47 +0100
commitf0428c18f85692f11ddd28fc12e949c420e971c9 (patch)
tree71d3afa04cc114cb840e7ffc534513505ddfd3a0 /guix/inferior.scm
parent1007640a63de6749a93e94a2751f66af56b01d07 (diff)
downloadguix-f0428c18f85692f11ddd28fc12e949c420e971c9.tar.gz
inferior: Allow controlling the inferior error port.
Previously, stderr for the inferior process would always be sent to /dev/null
because the current-output-port when the process is launched is a void
port. This change means that it's possible to pass in a different port to use.

* guix/inferior.scm (inferior-pipe): Take the error-port as an argument.
(open-inferior): Add new error-port keyword argument, with a default
of (%make-void-port "w").
Diffstat (limited to 'guix/inferior.scm')
-rw-r--r--guix/inferior.scm10
1 files changed, 6 insertions, 4 deletions
diff --git a/guix/inferior.scm b/guix/inferior.scm
index d6d2053ab8..eecdbdd5ca 100644
--- a/guix/inferior.scm
+++ b/guix/inferior.scm
@@ -110,11 +110,11 @@
   (packages inferior-package-promise)            ;promise of inferior packages
   (table    inferior-package-table))             ;promise of vhash
 
-(define (inferior-pipe directory command)
+(define* (inferior-pipe directory command error-port)
   "Return an input/output pipe on the Guix instance in DIRECTORY.  This runs
 'DIRECTORY/COMMAND repl' if it exists, or falls back to some other method if
 it's an old Guix."
-  (let ((pipe (with-error-to-port (%make-void-port "w")
+  (let ((pipe (with-error-to-port error-port
                 (lambda ()
                   (open-pipe* OPEN_BOTH
                               (string-append directory "/" command)
@@ -161,11 +161,13 @@ inferior."
     (_
      #f)))
 
-(define* (open-inferior directory #:key (command "bin/guix"))
+(define* (open-inferior directory
+                        #:key (command "bin/guix")
+                        (error-port (%make-void-port "w")))
   "Open the inferior Guix in DIRECTORY, running 'DIRECTORY/COMMAND repl' or
 equivalent.  Return #f if the inferior could not be launched."
   (define pipe
-    (inferior-pipe directory command))
+    (inferior-pipe directory command error-port))
 
   (port->inferior pipe close-pipe))