feat: cd builtin

pull/5/head
TorchedSammy 2021-03-20 01:22:43 -04:00
parent e6d625012d
commit 9c08954c2f
1 changed files with 9 additions and 7 deletions

16
main.go
View File

@ -66,14 +66,16 @@ func main() {
switch cmdArgs[0] {
case "exit":
os.Exit(0)
}
case "cd":
os.Chdir(strings.Trim(cmdString, "cd "))
default:
cmd := exec.Command(cmdArgs[0], cmdArgs[1:]...)
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
cmd := exec.Command(cmdArgs[0], cmdArgs[1:]...)
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
if err := cmd.Run(); err != nil {
fmt.Fprintln(os.Stderr, err)
if err := cmd.Run(); err != nil {
fmt.Fprintln(os.Stderr, err)
}
}
readline.AddHistory(cmdString)
}