all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dan Frumin <dfrumin@cs.ru.nl>
To: 36021@debbugs.gnu.org
Cc: Dan Frumin <dfrumin@cs.ru.nl>
Subject: [bug#36021] [PATCH] search-paths: 'environment-variable-definition' output for fish
Date: Fri, 31 May 2019 12:36:30 +0200	[thread overview]
Message-ID: <20190531103630.6739-1-dfrumin@cs.ru.nl> (raw)

---
 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	other threads:[~2019-05-31 10:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-31 10:36 Dan Frumin [this message]
2019-05-31 10:41 ` [bug#36021] [PATCH] search-paths: 'environment-variable-definition' output for fish 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190531103630.6739-1-dfrumin@cs.ru.nl \
    --to=dfrumin@cs.ru.nl \
    --cc=36021@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.