mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 20:31:19 -03:00
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
This commit is contained in:
32
tests/checks/export.fish
Normal file
32
tests/checks/export.fish
Normal file
@@ -0,0 +1,32 @@
|
||||
#RUN: %fish %s
|
||||
|
||||
false
|
||||
export FOO=bar
|
||||
echo $status
|
||||
# CHECK: 0
|
||||
set -S FOO
|
||||
# CHECK: $FOO: set in global scope, exported, with 1 elements
|
||||
# CHECK: $FOO[1]: |bar|
|
||||
|
||||
## Test path variable that is not already set.
|
||||
set -eg MANPATH
|
||||
export MANPATH=":/path/to/man/pages"
|
||||
echo $status
|
||||
# CHECK: 0
|
||||
set -S MANPATH
|
||||
# CHECK: $MANPATH: set in global scope, exported, a path variable with 2 elements
|
||||
# CHECK: $MANPATH[1]: ||
|
||||
# CHECK: $MANPATH[2]: |/path/to/man/pages|
|
||||
|
||||
## Re-set a path variable that is already set.
|
||||
export MANPATH="/some/path:/some/other/path"
|
||||
echo $status
|
||||
# CHECK: 0
|
||||
set -S MANPATH
|
||||
# CHECK: $MANPATH: set in global scope, exported, a path variable with 2 elements
|
||||
# CHECK: $MANPATH[1]: |/some/path|
|
||||
# CHECK: $MANPATH[2]: |/some/other/path|
|
||||
|
||||
## Test that it's exported properly.
|
||||
env | string match 'MANPATH*'
|
||||
# CHECK: MANPATH=/some/path:/some/other/path
|
||||
Reference in New Issue
Block a user