aboutsummaryrefslogtreecommitdiff
path: root/go/weed/shell.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2013-02-26 22:54:22 -0800
committerChris Lu <chris.lu@gmail.com>2013-02-26 22:54:22 -0800
commitdb8e27be6ec7daa1a188f90f61e385c04cb6b008 (patch)
tree33e53b6ec51157709bc6121adeb8b19fe668c79b /go/weed/shell.go
parentbd278337db4e3c1937f2d7cd1623ee9627c77619 (diff)
downloadseaweedfs-db8e27be6ec7daa1a188f90f61e385c04cb6b008.tar.xz
seaweedfs-db8e27be6ec7daa1a188f90f61e385c04cb6b008.zip
add lots of error checking by GThomas
Diffstat (limited to 'go/weed/shell.go')
-rw-r--r--go/weed/shell.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/go/weed/shell.go b/go/weed/shell.go
index daf0b7e1f..4287f2148 100644
--- a/go/weed/shell.go
+++ b/go/weed/shell.go
@@ -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
}