fix: added better debug logging for core.Exec (fixes #1125)

This commit is contained in:
Simone Margaritelli 2024-09-13 12:27:22 +02:00
commit 5bc9dd9259
3 changed files with 26 additions and 8 deletions

View file

@ -4,6 +4,7 @@ import (
"os/exec"
"sort"
"github.com/bettercap/bettercap/v2/log"
"github.com/evilsocket/islazy/str"
)
@ -36,10 +37,13 @@ func HasBinary(executable string) bool {
func Exec(executable string, args []string) (string, error) {
path, err := exec.LookPath(executable)
if err != nil {
log.Warning("executable %s not found in $PATH", executable)
return "", err
}
raw, err := exec.Command(path, args...).CombinedOutput()
log.Debug("exec=%s args=%v ret_err=%v ret_out=%s", path, args, err, string(raw))
if err != nil {
return str.Trim(string(raw)), err
} else {