[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/02: scripts: repl: Add -i, --interactive flag.

From: guix-commits
Subject: 02/02: scripts: repl: Add -i, --interactive flag.
Date: Mon, 16 Jan 2023 09:00:43 -0500 (EST)

apteryx pushed a commit to branch master
in repository guix.

commit 93e683a9527563bd5bc815d1a2c90cdf28957080
Author: Antero Mejr <>
AuthorDate: Sat Dec 3 01:09:37 2022 +0000

    scripts: repl: Add -i, --interactive flag.
    * guix/scripts/repl.scm (%options): Add -i, --interactive flag.
    (guix-repl): Honor -i, --interactive flag.
    * doc/guix.texi (Invoking guix repl): Add documentation for -i, 
    Signed-off-by: Maxim Cournoyer <>
 doc/guix.texi         | 13 +++++++++++++
 guix/scripts/repl.scm |  8 +++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index e8cd2a90a0..c2facdd9a8 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -111,6 +111,7 @@ Copyright @copyright{} 2022 (@*
 Copyright @copyright{} 2022 John Kehayias@*
 Copyright @copyright{} 2022 Ivan Vilata-i-Balaguer@*
 Copyright @copyright{} 2023 Giacomo Leidi@*
+Copyright @copyright{} 2022 Antero Mejr <>
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -12012,6 +12013,14 @@ lines at the top of the script:
 @end example
+To make a script that launches an interactive REPL directly from the
+shell, use the @code{--interactive} flag:
+@code{#!/usr/bin/env -S guix repl --interactive}
+@end example
 Without a file name argument, a Guile REPL is started, allowing for
 interactive use (@pxref{Using Guix Interactively}):
@@ -12060,6 +12069,10 @@ Accept connections on localhost on port 37146.
 Accept connections on the Unix-domain socket @file{/tmp/socket}.
 @end table
+@item --interactive
+@itemx -i
+Launch the interactive REPL after @var{file} is executed.
 @item --load-path=@var{directory}
 @itemx -L @var{directory}
 Add @var{directory} to the front of the package module search path
diff --git a/guix/scripts/repl.scm b/guix/scripts/repl.scm
index 0ec62786e9..787c63d48e 100644
--- a/guix/scripts/repl.scm
+++ b/guix/scripts/repl.scm
@@ -62,6 +62,9 @@
         (option '(#\q) #f #f
                 (lambda (opt name arg result)
                   (alist-cons 'ignore-dot-guile? #t result)))
+        (option '(#\i "interactive") #f #f
+                (lambda (opt name arg result)
+                  (alist-cons 'interactive? #t result)))
         (option '(#\L "load-path") #t #f
                 (lambda (opt name arg result)
                   ;; XXX: Imperatively modify the search paths.
@@ -84,6 +87,9 @@ command-line arguments ARGS.  If no FILE is given, start a 
Guile REPL.\n"))
   -q                     inhibit loading of ~/.guile"))
   (display (G_ "
+  -i, --interactive      launch REPL after evaluating FILE"))
+  (newline)
+  (display (G_ "
   -L, --load-path=DIR    prepend DIR to the package module search path"))
   (display (G_ "
@@ -196,7 +202,7 @@ call THUNK."
          ;; file in %LOAD-PATH.  Thus, pass (getcwd) instead of ".".
          (load-in-vicinity (getcwd) (car script)))))
-    (when (null? script)
+    (when (or (null? script) (assoc-ref opts 'interactive?))
       ;; Start REPL
       (let ((type (assoc-ref opts 'type)))
         (call-with-connection (assoc-ref opts 'listen)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]