mirror of https://github.com/Hilbis/Hilbish
feat: cd builtin
parent
e6d625012d
commit
9c08954c2f
6
main.go
6
main.go
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue