Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle environment variables with = signs correctly #2403

wants to merge 1 commit into from


Copy link

@crmne crmne commented Sep 18, 2015


I need to run this line:

export THEANO_FLAGS='floatX=float32,device=gpu,nvcc.fastmath=True'

but the current implementation of the export function doesn't export anything, since the tr command would split the string at all the occurrences of the equal sign and end up having no case in the switch statement.


By using sed we ensure that the string gets split at only the first occurrence of the equal sign, emulating more carefully bash's behavior.

Copy link

@faho faho commented Sep 18, 2015

This sounds okay, but I'd like a comment codifying this, so someone touching it (and I'll probably touch every single sed invocation in our codebase shortly) knows this is intentional.

@faho faho closed this in 20e96df Sep 24, 2015
Copy link

@faho faho commented Sep 24, 2015

Hi, I've now pushed a slightly different solution using our new cool string tool, including a comment.

Still thanks for your contribution!

@faho faho added this to the next-2.x milestone Sep 24, 2015
Copy link

@lledey lledey commented Oct 12, 2015

There is an issue with this fix, the \n is interpreted as "\n" instead of a line return.
I can't make a pull request but the fix is very simple.

diff --git a/share/functions/ b/share/functions/
index 7c6248e..5ffd27d 100644
--- a/share/functions/
+++ b/share/functions/
@@ -5,7 +5,7 @@ function export --description 'Set global variable. Alias for set -gx, made for
         for arg in $argv
                        # Only split on the first =
-            set -l v (echo $arg | string replace "=" "\n")
+            set -l v (echo $arg | string replace "=" \n)
             set -l c (count $v)
             switch $c
                     case 1
Copy link

@faho faho commented Oct 12, 2015

@lledey: Well, that's embarassing. Thanks for pointing it out! Fixed in 54f2152.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants