]> git.lizzy.rs Git - micro.git/blob - cmd/micro/shellwords/util_windows.go
Code optimisation (#1117)
[micro.git] / cmd / micro / shellwords / util_windows.go
1 package shellwords
2
3 import (
4         "errors"
5         "os"
6         "os/exec"
7         "strings"
8 )
9
10 func shellRun(line string) (string, error) {
11         shell := os.Getenv("COMSPEC")
12         b, err := exec.Command(shell, "/c", line).Output()
13         if err != nil {
14                 if eerr, ok := err.(*exec.ExitError); ok {
15                         b = eerr.Stderr
16                 }
17                 return "", errors.New(err.Error() + ":" + string(b))
18         }
19         return strings.TrimSpace(string(b)), nil
20 }