From ce405612043810f74b2823d1efff898d020eb6d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 9 Apr 2018 01:00:11 +0200 Subject: evaluate: Change directory to SOURCE. * bin/evaluate.in (with-directory-excursion): Remove. (main): chdir to SOURCE. --- bin/evaluate.in | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'bin') diff --git a/bin/evaluate.in b/bin/evaluate.in index 3d5bbb6..985b787 100644 --- a/bin/evaluate.in +++ b/bin/evaluate.in @@ -35,17 +35,6 @@ exec ${GUILE:-@GUILE@} --no-auto-compile -e main -s "$0" "$@" (let ((m (resolve-interface module))) (module-ref m name))) -(define-syntax-rule (with-directory-excursion dir body ...) - "Run BODY with DIR as the process's current directory." - (let ((init (getcwd))) - (dynamic-wind - (lambda () - (chdir dir)) - (lambda () - body ...) - (lambda () - (chdir init))))) - (define %not-colon (char-set-complement (char-set #\:))) @@ -66,18 +55,22 @@ exec ${GUILE:-@GUILE@} --no-auto-compile -e main -s "$0" "$@" (unless (string-null? guix-package-path) (setenv "GUIX_PACKAGE_PATH" guix-package-path)) + ;; Since we have relative file name canonicalization by default, better + ;; change to SOURCE to make sure things like 'include' with relative + ;; file names work as expected. + (chdir source) + (save-module-excursion (lambda () (set-current-module %user-module) - (with-directory-excursion source - (let ((original-path %load-path)) - (dynamic-wind - (lambda () - (set! %load-path (append load-path original-path))) - (lambda () - (primitive-load (assq-ref spec #:file))) - (lambda () - (set! %load-path original-path))))))) + (let ((original-path %load-path)) + (dynamic-wind + (lambda () + (set! %load-path (append load-path original-path))) + (lambda () + (primitive-load (assq-ref spec #:file))) + (lambda () + (set! %load-path original-path)))))) ;; From there on we can access Guix modules. -- cgit v1.2.3