add lots of error checking by GThomas

This commit is contained in:
Chris Lu
2013-02-26 22:54:22 -08:00
parent bd278337db
commit db8e27be6e
29 changed files with 268 additions and 170 deletions

View File

@@ -3,6 +3,7 @@ package main
import (
"bufio"
"fmt"
"log"
"os"
)
@@ -25,8 +26,13 @@ func runShell(command *Command, args []string) bool {
o := bufio.NewWriter(os.Stdout)
e := bufio.NewWriter(os.Stderr)
prompt := func() {
o.WriteString("> ")
o.Flush()
var err error
if _, err = o.WriteString("> "); err != nil {
log.Printf("error writing to stdout: %s", err)
}
if err = o.Flush(); err != nil {
log.Printf("error flushing stdout: %s", err)
}
}
readLine := func() string {
ret, err := r.ReadString('\n')
@@ -38,7 +44,9 @@ func runShell(command *Command, args []string) bool {
}
execCmd := func(cmd string) int {
if cmd != "" {
o.WriteString(cmd)
if _, err := o.WriteString(cmd); err != nil {
log.Printf("error writing to stdout: %s", err)
}
}
return 0
}