2019-03-19 11:21:03 -04:00
|
|
|
// +build windows,go1.6
|
|
|
|
|
2017-04-17 18:08:24 -04:00
|
|
|
package shellwords
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func shellRun(line string) (string, error) {
|
|
|
|
shell := os.Getenv("COMSPEC")
|
|
|
|
b, err := exec.Command(shell, "/c", line).Output()
|
|
|
|
if err != nil {
|
2019-03-19 11:21:03 -04:00
|
|
|
if eerr, ok := err.(*exec.ExitError); ok {
|
|
|
|
b = eerr.Stderr
|
|
|
|
}
|
2017-04-17 18:08:24 -04:00
|
|
|
return "", errors.New(err.Error() + ":" + string(b))
|
|
|
|
}
|
|
|
|
return strings.TrimSpace(string(b)), nil
|
|
|
|
}
|