From 408f2110ea96da62959c83c386b6c9a9db5cedae Mon Sep 17 00:00:00 2001 From: jet2tlf Date: Wed, 29 May 2024 23:24:56 -0300 Subject: pass 4st stage --- cmd/myshell/main.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'cmd') diff --git a/cmd/myshell/main.go b/cmd/myshell/main.go index 5626017..24f1fc4 100644 --- a/cmd/myshell/main.go +++ b/cmd/myshell/main.go @@ -18,14 +18,10 @@ func main() { fmt.Println(err.Error()) } - commands := strings.Split(in, " ") - - switch in { - case commands[0] == "exit": - n, err := strconv.Atoi(commands[1]) - os.Exit(n) + if in == "exit 0" { + os.Exit(0) + } else { + fmt.Printf("%s: command not found\n", strings.TrimRight(in, "\n")) } - - fmt.Printf("%s: command not found\n", strings.TrimRight(in, "\n")) } } -- cgit v1.2.3