elvish/pkg/eval/builtin_ns.go

33 lines
861 B
Go
Raw Normal View History

package eval
import (
"embed"
"strconv"
"syscall"
2018-01-01 23:21:15 +08:00
"src.elv.sh/pkg/buildinfo"
"src.elv.sh/pkg/eval/vars"
)
var builtinNs = BuildNsNamed("").AddVars(map[string]vars.Var{
"_": vars.NewBlackhole(),
"pid": vars.NewReadOnly(strconv.Itoa(syscall.Getpid())),
"ok": vars.NewReadOnly(OK),
"nil": vars.NewReadOnly(nil),
"true": vars.NewReadOnly(true),
"false": vars.NewReadOnly(false),
"buildinfo": vars.NewReadOnly(buildinfo.Value),
"version": vars.NewReadOnly(buildinfo.Value.Version),
"paths": vars.NewEnvListVar("PATH"),
"nop" + FnSuffix: vars.NewReadOnly(nopGoFn),
})
2017-06-28 07:39:05 +08:00
func addBuiltinFns(fns map[string]any) {
builtinNs.AddGoFns(fns)
}
// BuiltinDElvFiles embeds all the .d.elv files for the builtin module.
//
//go:embed *.d.elv
var BuiltinDElvFiles embed.FS