summaryrefslogtreecommitdiff
path: root/cmds/exit.go
blob: 5170b26416878fec3b3c3e3bc23f6710a7f8bf79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package cmds

import (
	"errors"
	"os"
	"strconv"
)

// exit the shell and returns the provided status
// if no status is specified returns 0
func exit(args []string) error {
	status := 0
	if len(args) > 1 {
		var err error
		status, err = strconv.Atoi(args[1])
		if err != nil {
			return errors.New("usage: exit (status)")
		}
	}
	os.Exit(status)
	return nil
}