guix-patches
[Top][All Lists]
Advanced

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

[bug#36021] [PATCH] search-paths: 'environment-variable-definition' outp


From: Dan Frumin
Subject: [bug#36021] [PATCH] search-paths: 'environment-variable-definition' output for fish
Date: Fri, 31 May 2019 12:36:30 +0200

---
 guix/search-paths.scm | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/guix/search-paths.scm b/guix/search-paths.scm
index 002e6342bb..fe9253e88e 100644
--- a/guix/search-paths.scm
+++ b/guix/search-paths.scm
@@ -177,15 +177,28 @@ 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 (if (not separator) 'exact 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))))
+  (let* ([shell-env (getenv "SHELL")]
+         [is-fish? (and shell-env
+                        (equal? (last (string-split shell-env #\/))
+                                "fish"))])
+   (match (if (not separator) 'exact kind)
+     ('exact
+      (if is-fish?
+          ;; See <https://fishshell.com/docs/current/commands.html#set> for 
syntax
+          (format #f "set -x ~a \"~a\"" variable value)
+          (format #f "export ~a=\"~a\"" variable value)))
+     ('prefix
+      (if is-fish?
+          (format #f "set -x ~a \"~a\" $~a"
+                  variable value variable)
+          (format #f "export ~a=\"~a${~a:+~a}$~a\""
+                  variable value variable separator variable)))
+     ('suffix
+      (if is-fish?
+          (format #f "set -x ~a $~a \"~a\""
+                  variable variable value)
+          (format #f "export ~a=\"$~a${~a:+~a}~a\""
+                  variable variable variable separator value))))))
 
 (define* (search-path-definition search-path value
                                  #:key (kind 'exact))
-- 
2.17.1






reply via email to

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