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