Fix: Issue with copying

This commit is contained in:
kayos@tcp.direct 2024-06-19 09:45:23 -07:00
parent 0170b7cd90
commit b618f7348c
No known key found for this signature in database
GPG key ID: 4B841471B4BEE979
3 changed files with 70 additions and 5 deletions

View file

@ -133,8 +133,14 @@ func ExecAndLogSudo(isRoot, noisy bool, cmd string) error {
fmt.Printf("Executing (elevated): %s\nSee debug.log for detailed output\n", cmd)
}
wd, err := os.Getwd()
if err != nil {
return err
}
cs := strings.Fields(cmd)
r := exec.Command(cs[0], cs[1:]...)
r.Dir = wd
cmdCombinedOut, err := r.CombinedOutput()
outStr := string(cmdCombinedOut)
@ -148,5 +154,9 @@ func ExecAndLogSudo(isRoot, noisy bool, cmd string) error {
fmt.Printf("%s\n", outStr)
}
if err != nil {
err = fmt.Errorf("failed to execute %s: %w\n%s", cmd, err, outStr)
}
return err
}