repl: Look for script files in (getcwd).
authorKonrad Hinsen <konrad.hinsen@fastmail.net>
Fri, 11 Sep 2020 11:13:26 +0000 (13:13 +0200)
committerLudovic Courtès <ludo@gnu.org>
Wed, 16 Sep 2020 14:04:01 +0000 (16:04 +0200)
Fixes <https://bugs.gnu.org/43331>.

* guix/scripts/repl.scm (guix-repl): Replace "." by (getcwd)
* tests/guix-repl.sh: Add test.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
guix/scripts/repl.scm
tests/guix-repl.sh

index 3c79e89..7d4e474 100644 (file)
@@ -178,7 +178,10 @@ call THUNK."
        (lambda ()
          (set-program-arguments script)
          (set-user-module)
-         (load-in-vicinity "." (car script)))))
+
+         ;; When passed a relative file name, 'load-in-vicinity' searches the
+         ;; file in %LOAD-PATH.  Thus, pass (getcwd) instead of ".".
+         (load-in-vicinity (getcwd) (car script)))))
 
     (when (null? script)
       ;; Start REPL
index e1c2b82..d4ebb5f 100644 (file)
@@ -45,6 +45,10 @@ EOF
 
 test "`guix repl "$tmpfile"`" = "coreutils"
 
+# Make sure that the file can also be loaded when passed as a relative file
+# name.
+(cd "$(dirname "$tmpfile")"; test "$(guix repl "$(basename "$tmpfile")")" = "coreutils")
+
 
 cat > "$module_dir/foo.scm"<<EOF
 (define-module (foo)