// Package shell is the entry point for the terminal interface of Elvish.
package shell import ( ) var logger = logutil.GetLogger("[shell] ") // Program is the shell subprogram. var Program prog.Program = program{} type program struct{} func (program) (*prog.Flags) bool { return true } func (program) ( [3]*os.File, *prog.Flags, []string) error { := MakePaths([2], Paths{Bin: .Bin, Sock: .Sock, Db: .DB}) if .NoRc { .Rc = "" } if len() > 0 { := Script( , , &ScriptConfig{ Paths: , Cmd: .CodeInArg, CompileOnly: .CompileOnly, JSON: .JSON}) return prog.Exit() } Interact(, &InteractConfig{SpawnDaemon: true, Paths: }) return nil } func ( [3]*os.File, Paths, bool) (*eval.Evaler, func()) { := term.SetupGlobal() := InitRuntime([2], , ) := incSHLVL() := sys.NotifySignals() go func() { for := range { logger.Println("signal", ) handleSignal(, [2]) } }() return , func() { signal.Stop() () CleanupRuntime([2], ) () } } func ( *eval.Evaler, [3]*os.File, parse.Source) (float64, error) { := time.Now() , := eval.PortsFromFiles(, .ValuePrefix()) defer () := .Eval(, eval.EvalCfg{ Ports: , Interrupt: eval.ListenInterrupts, PutInFg: true}) := time.Now() return .Sub().Seconds(), } func () func() { := saveEnv(env.SHLVL) , := strconv.Atoi(os.Getenv(env.SHLVL)) if != nil { = 0 } os.Setenv(env.SHLVL, strconv.Itoa(+1)) return } func ( string) func() { , := os.LookupEnv() if { return func() { os.Setenv(, ) } } return func() { os.Unsetenv() } }