all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#36021] [PATCH] search-paths: 'environment-variable-definition' output for fish
@ 2019-05-31 10:36 Dan Frumin
  2019-05-31 10:41 ` Dan Frumin
  0 siblings, 1 reply; 8+ messages in thread
From: Dan Frumin @ 2019-05-31 10:36 UTC (permalink / raw)
  To: 36021; +Cc: Dan Frumin

---
 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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-06-04  7:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-31 10:36 [bug#36021] [PATCH] search-paths: 'environment-variable-definition' output for fish Dan Frumin
2019-05-31 10:41 ` Dan Frumin
2019-06-01 13:10   ` Ludovic Courtès
2019-06-02  9:29     ` Dan Frumin
2019-06-03  5:51   ` Meiyo Peng
2019-06-03 15:50     ` Dan Frumin
2019-06-04  3:53       ` Meiyo Peng
2019-06-04  7:48         ` Dan Frumin

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.