Find libraries in ~/.elvish/lib when use'ing.

This commit is contained in:
Qi Xiao 2017-02-01 12:03:54 -08:00
parent 216dad636e
commit 22562555ee

View File

@ -170,11 +170,11 @@ func use(ec *EvalCtx, modname string, pfilename *string) {
source, err = readFileUTF8(filename)
maybeThrow(err)
} else {
// No filename; defaulting to $datadir/$modname.elv.
// No filename; defaulting to $datadir/lib/$modname.elv.
if ec.DataDir == "" {
throw(ErrNoDataDir)
}
filename = ec.DataDir + "/" + strings.Replace(modname, ":", "/", -1) + ".elv"
filename = ec.DataDir + "/lib/" + strings.Replace(modname, ":", "/", -1) + ".elv"
if _, err := os.Stat(filename); os.IsNotExist(err) {
// File does not exist. Try loading from the table of builtin
// modules.