mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-01 08:42:55 +08:00
Treat $XDG_DATA_DIRS as semicolon-delimited on Windows.
This commit is contained in:
parent
2506b578b9
commit
6cb2fd3855
|
@ -5,7 +5,6 @@ import (
|
|||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"src.elv.sh/pkg/daemon/daemondefs"
|
||||
"src.elv.sh/pkg/env"
|
||||
|
@ -50,9 +49,10 @@ func libPaths(w io.Writer) ([]string, error) {
|
|||
}
|
||||
|
||||
if dataDirs := os.Getenv(env.XDG_DATA_DIRS); dataDirs != "" {
|
||||
// We intentionally do not use filepath.SplitList and always follow the
|
||||
// semantics of XDG, even on Windows.
|
||||
for _, dataDir := range strings.Split(dataDirs, ":") {
|
||||
// XDG requires the paths be joined with ":". However, on Windows ":"
|
||||
// appear after the drive letter, so it's infeasible to use it to also
|
||||
// join paths.
|
||||
for _, dataDir := range filepath.SplitList(dataDirs) {
|
||||
paths = append(paths, filepath.Join(dataDir, "elvish", "lib"))
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -53,7 +53,8 @@ func TestShell_LibPath_XDGPaths(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}, xdgDataDir2)
|
||||
testutil.Setenv(t, env.XDG_DATA_DIRS, xdgDataDir1+":"+xdgDataDir2)
|
||||
testutil.Setenv(t, env.XDG_DATA_DIRS,
|
||||
xdgDataDir1+string(filepath.ListSeparator)+xdgDataDir2)
|
||||
|
||||
Test(t, &Program{},
|
||||
ThatElvish("-c", "use a").WritesStdout("a from xdg-config-home\n"),
|
||||
|
|
|
@ -81,7 +81,8 @@ directories:
|
|||
`%LocalAppData%\elvish\lib` (Windows) is searched.
|
||||
|
||||
3. If the `XDG_DATA_DIRS` environment variable is defined and non-empty, it is
|
||||
treated as a colon-delimited list of paths, which are all searched.
|
||||
treated as a colon-delimited list of paths (semicolon-delimited on Windows),
|
||||
which are all searched.
|
||||
|
||||
Otherwise, `/usr/local/share/elvish/lib` and `/usr/share/elvish/lib` are
|
||||
searched on non-Windows OSes. On Windows, no directories are searched.
|
||||
|
|
Loading…
Reference in New Issue
Block a user