I need to run this line:
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.
Handle env vars with = signs correctly
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.
export: Enable values with "=" in them
Only split on the first "=" to achieve this.
Hi, I've now pushed a slightly different solution using our new cool string tool, including a comment.
Still thanks for your contribution!
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/export.fish b/share/functions/export.fish
index 7c6248e..5ffd27d 100644
@@ -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)
@lledey: Well, that's embarassing. Thanks for pointing it out! Fixed in 54f2152.