Mercurial > yakumo_izuru > aya
comparison zs.go @ 5:e0ee0721d34f draft
added tests for eval command runner
author | zaitsev.serge |
---|---|
date | Fri, 05 Dec 2014 18:21:42 +0000 |
parents | 05fc24caac37 |
children | cb66f5b86616 |
comparison
equal
deleted
inserted
replaced
4:05fc24caac37 | 5:e0ee0721d34f |
---|---|
108 | 108 |
109 func eval(cmd []string, vars map[string]string) (string, error) { | 109 func eval(cmd []string, vars map[string]string) (string, error) { |
110 outbuf := bytes.NewBuffer(nil) | 110 outbuf := bytes.NewBuffer(nil) |
111 err := run(path.Join(ZSDIR, cmd[0]), cmd[1:], vars, outbuf) | 111 err := run(path.Join(ZSDIR, cmd[0]), cmd[1:], vars, outbuf) |
112 if err != nil { | 112 if err != nil { |
113 log.Println(err) | 113 if _, ok := err.(*exec.ExitError); ok { |
114 return "", err | |
115 } | |
114 outbuf = bytes.NewBuffer(nil) | 116 outbuf = bytes.NewBuffer(nil) |
115 err := run(cmd[0], cmd[1:], vars, outbuf) | 117 err := run(cmd[0], cmd[1:], vars, outbuf) |
116 if err != nil { | 118 // Return exit errors, but ignore if the command was not found |
119 if _, ok := err.(*exec.ExitError); ok { | |
117 return "", err | 120 return "", err |
118 } | 121 } |
119 } | 122 } |
120 return outbuf.String(), nil | 123 return outbuf.String(), nil |
121 } | 124 } |