elvish/pkg/eval/builtin_ns.go

27 lines
727 B
Go
Raw Normal View History

package eval
import (
"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)
}