diff options
author | Ludovic Courtès <ludo@gnu.org> | 2016-06-16 22:24:14 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2016-06-16 23:50:44 +0200 |
commit | d4dd37fc4614859461952a251a49c1abb2d71ddc (patch) | |
tree | b5636bca780071ba15e236d4fdfab103c0551a6c /guix | |
parent | 5dbae738f0ff83bf629b53d6f4e52a8384a97fb1 (diff) | |
download | gnu-guix-d4dd37fc4614859461952a251a49c1abb2d71ddc.tar gnu-guix-d4dd37fc4614859461952a251a49c1abb2d71ddc.tar.gz |
utils: 'current-source-directory' returns the absolute directory name.
* guix/utils.scm (current-source-directory): When FILE-NAME is relative,
use 'search-path' to determine the absolute file name.
Diffstat (limited to 'guix')
-rw-r--r-- | guix/utils.scm | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/guix/utils.scm b/guix/utils.scm index 8aadfb0075..a642bd3d62 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -704,12 +704,18 @@ output port, and PROC's result is returned." (define-syntax current-source-directory (lambda (s) - "Return the current directory name or #f if it could not be determined." + "Return the absolute name of the current directory, or #f if it could not +be determined." (syntax-case s () ((_) (match (assq 'filename (syntax-source s)) (('filename . (? string? file-name)) - (dirname file-name)) + ;; If %FILE-PORT-NAME-CANONICALIZATION is 'relative, then FILE-NAME + ;; can be relative. In that case, we try to find out the absolute + ;; file name by looking at %LOAD-PATH. + (if (string-prefix? "/" file-name) + (dirname file-name) + (and=> (search-path %load-path file-name) dirname))) (_ #f)))))) |