From patchwork Fri May 31 10:36:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Frumin X-Patchwork-Id: 14168 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 6B58C17041; Fri, 31 May 2019 11:37:11 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 0913E1701E for ; Fri, 31 May 2019 11:37:11 +0100 (BST) Received: from localhost ([127.0.0.1]:40723 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWeuL-0005ID-59 for patchwork@mira.cbaines.net; Fri, 31 May 2019 06:37:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWeuF-0005I7-GQ for guix-patches@gnu.org; Fri, 31 May 2019 06:37:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hWeuD-0007uH-UL for guix-patches@gnu.org; Fri, 31 May 2019 06:37:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49538) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hWeuD-0007tx-RQ for guix-patches@gnu.org; Fri, 31 May 2019 06:37:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hWeuD-0002ot-NX for guix-patches@gnu.org; Fri, 31 May 2019 06:37:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#36021] [PATCH] search-paths: 'environment-variable-definition' output for fish Resent-From: Dan Frumin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 31 May 2019 10:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 36021 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 36021@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.155929901310813 (code B ref -1); Fri, 31 May 2019 10:37:01 +0000 Received: (at submit) by debbugs.gnu.org; 31 May 2019 10:36:53 +0000 Received: from localhost ([127.0.0.1]:34849 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hWeu4-0002oK-Nb for submit@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 ) id 1hWeu2-0002nv-P2 for submit@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 ) id 1hWetx-0007cd-Jz for submit@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 ) id 1hWetw-0005I0-Cs for guix-patches@gnu.org; Fri, 31 May 2019 06:36:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hWetv-0007Zz-2P for guix-patches@gnu.org; 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 ) id 1hWetu-0007Tq-QW for guix-patches@gnu.org; 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@cs.ru.nl) 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 Date: Fri, 31 May 2019 12:36:30 +0200 Message-Id: <20190531103630.6739-1-dfrumin@cs.ru.nl> 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-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dan Frumin Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches --- 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 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))