github.hscsec.cn/u-root/u-root@v7.0.0+incompatible/cmds/core/elvish/eval/builtin_fn_cmd.go (about)

     1  package eval
     2  
     3  import (
     4  	"errors"
     5  	"os"
     6  )
     7  
     8  // Command and process control.
     9  
    10  var ErrNotInSameGroup = errors.New("not in the same process group")
    11  
    12  func init() {
    13  	addBuiltinFns(map[string]interface{}{
    14  		// Process control
    15  		"fg":   fg,
    16  		"exec": execFn,
    17  		"exit": exit,
    18  	})
    19  }
    20  
    21  func exit(fm *Frame, codes ...int) error {
    22  	code := 0
    23  	switch len(codes) {
    24  	case 0:
    25  	case 1:
    26  		code = codes[0]
    27  	default:
    28  		return ErrArgs
    29  	}
    30  
    31  	preExit(fm)
    32  	os.Exit(code)
    33  	// Does not return
    34  	panic("os.Exit returned")
    35  }
    36  
    37  func preExit(fm *Frame) {
    38  }
    39  
    40  var errNotSupportedOnWindows = errors.New("not supported on Windows")
    41  
    42  func notSupportedOnWindows() error {
    43  	return errNotSupportedOnWindows
    44  }