[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/08: search-paths: Add 'environment-variable-definition'.
From: |
Ludovic Courtès |
Subject: |
05/08: search-paths: Add 'environment-variable-definition'. |
Date: |
Mon, 04 May 2015 21:31:01 +0000 |
civodul pushed a commit to branch master
in repository guix.
commit b07901c0cc5b36efdc92263ddeaa2be28cf2f398
Author: Ludovic Courtès <address@hidden>
Date: Mon May 4 22:06:24 2015 +0200
search-paths: Add 'environment-variable-definition'.
* guix/search-paths.scm (environment-variable-definition): New variable.
* guix/scripts/package.scm (search-path-environment-variables): Use it.
---
guix/scripts/package.scm | 2 +-
guix/search-paths.scm | 25 ++++++++++++++++++++++++-
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 933f7d8..9e433dd 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -384,7 +384,7 @@ current settings and report only settings not already
effective."
(append-map manifest-entry-search-paths entries))))
(filter-map (match-lambda
((variable . value)
- (format #f "export ~a=\"~a\"" variable value)))
+ (environment-variable-definition variable value)))
(evaluate-search-paths search-paths profile getenv))))
(define (display-search-paths entries profile)
diff --git a/guix/search-paths.scm b/guix/search-paths.scm
index b17f5ac..7957c88 100644
--- a/guix/search-paths.scm
+++ b/guix/search-paths.scm
@@ -33,7 +33,8 @@
search-path-specification->sexp
sexp->search-path-specification
- evaluate-search-paths))
+ evaluate-search-paths
+ environment-variable-definition))
;;; Commentary:
;;;
@@ -144,4 +145,26 @@ current settings and report only settings not already
effective."
(filter-map search-path-definition search-paths))
+(define* (environment-variable-definition variable value
+ #:key
+ (kind 'exact)
+ (separator ":"))
+ "Return a the definition of VARIABLE to VALUE in Bash syntax:
+
+KIND can be either 'exact (return the definition of VARIABLE=VALUE),
+'prefix (return the definition where VALUE is added as a prefix to VARIABLE's
+current value), or 'suffix (return the definition where VALUE is added as a
+suffix to VARIABLE's current value.) In the case of 'prefix and 'suffix,
+SEPARATOR is used as the separator between VARIABLE's current value and its
+prefix/suffix."
+ (match kind
+ ('exact
+ (format #f "export ~a=\"~a\"" variable value))
+ ('prefix
+ (format #f "export ~a=\"~a${~a:+~a}$~a\""
+ variable value variable separator variable))
+ ('suffix
+ (format #f "export ~a=\"$~a${~a:+~a}~a\""
+ variable variable variable separator value))))
+
;;; search-paths.scm ends here
- branch master updated (2534fc0 -> 954cea3), Ludovic Courtès, 2015/05/04
- 01/08: substitute: Increase TTL from 24h to 36h., Ludovic Courtès, 2015/05/04
- 02/08: gnu: Add markdown., Ludovic Courtès, 2015/05/04
- 05/08: search-paths: Add 'environment-variable-definition'.,
Ludovic Courtès <=
- 07/08: profiles: Use a &message error condition instead of 'error'., Ludovic Courtès, 2015/05/04
- 06/08: search-paths: 'evaluate-search-paths' now returns spec/value pairs., Ludovic Courtès, 2015/05/04
- 03/08: Move search path specifications to (guix search-paths)., Ludovic Courtès, 2015/05/04
- 08/08: records: Make 'make-syntactic-constructor' available at load/eval/expand., Ludovic Courtès, 2015/05/04
- 04/08: search-paths: Add 'evaluate-search-paths', from (guix scripts package)., Ludovic Courtès, 2015/05/04