Files
fish-shell/share/functions/export.fish
Johannes Altmanninger cb92a5530f functions/export: fix for path variables
Commit f38646593c (Allow `export` to set colon-separated `PATH`, `CDPATH`
and `MANPATH`., 2017-02-10)
did something very weird for «export PATH=foo».
It essentially does

	set -gx PATH (string replace -- "$PATH" (string join ":" -- $PATH) foo)

which makes no sense.  It should set PATH to "foo", no need to involve the
existing value of $PATH.

Additionally, the string split / string join dance is unnecessary.  Nowadays,
builtin set already handles path variables as is needed here, so get rid of
this special case.

Fixes #11434
2025-05-04 18:06:18 +02:00

18 lines
433 B
Fish

function export --description 'Set env variable. Alias for `set -gx` for bash compatibility.'
if not set -q argv[1]
set -x
return 0
end
for arg in $argv
set -l v (string split -m 1 "=" -- $arg)
set -l value
switch (count $v)
case 1
set value $$v[1]
case 2
set value $v[2]
end
set -gx $v[1] $value
end
end