blob: 562601790c314ba69de58481859aa09c8f16ab36 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package main
import (
"bufio"
"fmt"
"os"
"strings"
"strconv"
)
func main() {
stdin := bufio.NewReader(os.Stdin)
for {
fmt.Fprint(os.Stdout, "$ ")
in, err := stdin.ReadString('\n')
if err != nil {
fmt.Println(err.Error())
}
commands := strings.Split(in, " ")
switch in {
case commands[0] == "exit":
n, err := strconv.Atoi(commands[1])
os.Exit(n)
}
fmt.Printf("%s: command not found\n", strings.TrimRight(in, "\n"))
}
}
|