GNU bug report logs - #36021
[PATCH] search-paths: 'environment-variable-definition' output for fish

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Dan Frumin <dfrumin@HIDDEN>; Keywords: patch; dated Fri, 31 May 2019 10:37:01 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 36021 <at> debbugs.gnu.org:


Received: (at 36021) by debbugs.gnu.org; 1 Jun 2019 13:10:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 01 09:10:44 2019
Received: from localhost ([127.0.0.1]:37502 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hX3mW-0005mF-9F
	for submit <at> debbugs.gnu.org; Sat, 01 Jun 2019 09:10:44 -0400
Received: from eggs.gnu.org ([209.51.188.92]:55256)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1hX3mV-0005lz-2H
 for 36021 <at> debbugs.gnu.org; Sat, 01 Jun 2019 09:10:43 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:38357)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1hX3mM-0003dG-Iz; Sat, 01 Jun 2019 09:10:35 -0400
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=54788 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1hX3mK-0007VF-2z; Sat, 01 Jun 2019 09:10:34 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Dan Frumin <dfrumin@HIDDEN>
Subject: Re: [bug#36021] [PATCH] search-paths:
 'environment-variable-definition' output for fish
References: <20190531103630.6739-1-dfrumin@HIDDEN>
 <4c3d1d91-18ae-954f-2f0f-a979a974fb2c@HIDDEN>
Date: Sat, 01 Jun 2019 15:10:30 +0200
In-Reply-To: <4c3d1d91-18ae-954f-2f0f-a979a974fb2c@HIDDEN> (Dan Frumin's
 message of "Fri, 31 May 2019 12:41:10 +0200")
Message-ID: <87v9xpfo3d.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 36021
Cc: 36021 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi,

Dan Frumin <dfrumin@HIDDEN> skribis:

> Some background on this patch:
> Right now whenever I do any Guix operation that requires me to modify
> environment variables (e.g. installing a Guile library requires me to
> update $GUILE_LOAD_PATH afterwards), Guix helpful tells me what
> commands I have to run to update the variables.

But see <https://issues.guix.gnu.org/issue/35942>.  :-)

> However, those commands are currently in bash/POSIX(?) format `export
> VAR=3DVALUE`. I've modified the `environment-variable-definition`
> function to support the syntax for Fish shell as well. I don't know if
> this method of looking at the $SHELL variable is sound, but it works
> on my machine.

=E2=80=9Cexport VAR=3DVALUE=E2=80=9D is actually Bash-specific.  The POSIX =
way to do it
is:

  VAR=3DVALUE; export VAR

Would that work with Fish?

If it does, we might just as well take that route as it will also cater
to other POSIX-compatible shells.

If not, your patch sounds like the right way.

Thanks,
Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#36021; Package guix-patches. Full text available.

Message received at 36021 <at> debbugs.gnu.org:


Received: (at 36021) by debbugs.gnu.org; 31 May 2019 10:41:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 31 06:41:13 2019
Received: from localhost ([127.0.0.1]:34865 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hWeyH-00033A-Aw
	for submit <at> debbugs.gnu.org; Fri, 31 May 2019 06:41:13 -0400
Received: from smtp2.science.ru.nl ([131.174.16.145]:57948)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dfrumin@HIDDEN>) id 1hWeyF-000332-Ky
 for 36021 <at> debbugs.gnu.org; Fri, 31 May 2019 06:41:12 -0400
Received: from [192.168.4.18] (ip565a9ee0.direct-adsl.nl [86.90.158.224] (may
 be forged)) (authen=dfrumin)
 by smtp2.science.ru.nl (8.14.4/5.32) with ESMTP id x4VAfAOV018480
 for <36021 <at> debbugs.gnu.org>; Fri, 31 May 2019 12:41:10 +0200
Subject: Re: [PATCH] search-paths: 'environment-variable-definition' output
 for fish
To: 36021 <at> debbugs.gnu.org
References: <20190531103630.6739-1-dfrumin@HIDDEN>
From: Dan Frumin <dfrumin@HIDDEN>
Message-ID: <4c3d1d91-18ae-954f-2f0f-a979a974fb2c@HIDDEN>
Date: Fri, 31 May 2019 12:41:10 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
 Thunderbird/60.6.1
MIME-Version: 1.0
In-Reply-To: <20190531103630.6739-1-dfrumin@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 36021
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi Guix!

Some background on this patch:
Right now whenever I do any Guix operation that requires me to modify environment variables (e.g. installing a Guile library requires me to update 
$GUILE_LOAD_PATH afterwards), Guix helpful tells me what commands I have to run to update the variables.

However, those commands are currently in bash/POSIX(?) format `export VAR=VALUE`. I've modified the `environment-variable-definition` function to 
support the syntax for Fish shell as well. I don't know if this method of looking at the $SHELL variable is sound, but it works  on my machine.

Documentation for the `set' function in Fish: https://fishshell.com/docs/current/commands.html#set

PS: this is my first non-package patch for Guix so I apologize if there is something wrong with the patch

Best regards,
-Dan




Information forwarded to guix-patches@HIDDEN:
bug#36021; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 31 May 2019 10:36:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 31 06:36:53 2019
Received: from localhost ([127.0.0.1]:34849 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hWeu4-0002oK-Nb
	for submit <at> debbugs.gnu.org; Fri, 31 May 2019 06:36:52 -0400
Received: from eggs.gnu.org ([209.51.188.92]:39915)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dfrumin@HIDDEN>) id 1hWeu2-0002nv-P2
 for submit <at> debbugs.gnu.org; Fri, 31 May 2019 06:36:51 -0400
Received: from lists.gnu.org ([209.51.188.17]:41417)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <dfrumin@HIDDEN>) id 1hWetx-0007cd-Jz
 for submit <at> debbugs.gnu.org; Fri, 31 May 2019 06:36:45 -0400
Received: from eggs.gnu.org ([209.51.188.92]:54294)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <dfrumin@HIDDEN>) id 1hWetw-0005I0-Cs
 for guix-patches@HIDDEN; Fri, 31 May 2019 06:36:45 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_MED,
 URIBL_BLOCKED autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <dfrumin@HIDDEN>) id 1hWetv-0007Zz-2P
 for guix-patches@HIDDEN; Fri, 31 May 2019 06:36:44 -0400
Received: from smtp2.science.ru.nl ([131.174.16.145]:41408)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <dfrumin@HIDDEN>) id 1hWetu-0007Tq-QW
 for guix-patches@HIDDEN; Fri, 31 May 2019 06:36:43 -0400
Received: from localhost.localdomain (ip565a9ee0.direct-adsl.nl
 [86.90.158.224] (may be forged)) (authen=dfrumin@HIDDEN)
 by smtp2.science.ru.nl (8.14.4/5.32) with ESMTP id x4VAaV7q018080;
 Fri, 31 May 2019 12:36:34 +0200
From: Dan Frumin <dfrumin@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH] search-paths: 'environment-variable-definition' output for
 fish
Date: Fri, 31 May 2019 12:36:30 +0200
Message-Id: <20190531103630.6739-1-dfrumin@HIDDEN>
X-Mailer: git-send-email 2.17.1
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 131.174.16.145
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
Cc: Dan Frumin <dfrumin@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

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





Acknowledgement sent to Dan Frumin <dfrumin@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#36021; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 1 Jun 2019 13:15:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.