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

View File

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