mirror of
https://github.com/rancher/plugins.git
synced 2025-09-05 00:57:35 +00:00
go.mod: github.com/mattn/go-shellwords v1.0.11
adds go module support, among others Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
22
vendor/github.com/mattn/go-shellwords/util_windows.go
generated
vendored
22
vendor/github.com/mattn/go-shellwords/util_windows.go
generated
vendored
@@ -1,17 +1,29 @@
|
||||
// +build windows
|
||||
|
||||
package shellwords
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func shellRun(line string) (string, error) {
|
||||
shell := os.Getenv("COMSPEC")
|
||||
b, err := exec.Command(shell, "/c", line).Output()
|
||||
func shellRun(line, dir string) (string, error) {
|
||||
var shell string
|
||||
if shell = os.Getenv("COMSPEC"); shell == "" {
|
||||
shell = "cmd"
|
||||
}
|
||||
cmd := exec.Command(shell, "/c", line)
|
||||
if dir != "" {
|
||||
cmd.Dir = dir
|
||||
}
|
||||
b, err := cmd.Output()
|
||||
if err != nil {
|
||||
return "", errors.New(err.Error() + ":" + string(b))
|
||||
if eerr, ok := err.(*exec.ExitError); ok {
|
||||
b = eerr.Stderr
|
||||
}
|
||||
return "", fmt.Errorf("%s: %w", string(b), err)
|
||||
}
|
||||
return strings.TrimSpace(string(b)), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user