testing for using 'sudo'
This commit is contained in:
parent
d70cf82ecc
commit
2b1f7f54d5
Notes:
Jeff Carr
2025-02-14 19:19:37 -06:00
// `autogen:go.mod` module go.wit.com/lib/gui/shell go 1.22 toolchain go1.23.6 require ( github.com/go-cmd/cmd v1.4.3 go.wit.com/log v0.22.16 ) // `autogen:go.sum` github.com/go-cmd/cmd v1.4.3 h1:6y3G+3UqPerXvPcXvj+5QNPHT02BUw7p6PsqRxLNA7Y= github.com/go-cmd/cmd v1.4.3/go.mod h1:u3hxg/ry+D5kwh8WvUkHLAMe2zQCaXd00t35WfQaOFk= github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= go.wit.com/log v0.22.16 h1:E0Vd0Z2ILtfjhs7J/CQ4g13DK1jtQiYl6l5KOBGsZoA= go.wit.com/log v0.22.16/go.mod h1:/c5Uj30sWRQ4B5ei2ElB6Q8Si/cK6v+KbxnH208KD84= // `autogen:`
22
exec.go
22
exec.go
|
@ -49,6 +49,28 @@ func ExecCheck(args []string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func PathExecVerbose(path string, args []string) error {
|
||||
if len(args) == 0 {
|
||||
return errors.New("Error: Command slice is empty.")
|
||||
}
|
||||
|
||||
// Start a long-running process, capture stdout and stderr
|
||||
a, b := RemoveFirstElement(args)
|
||||
|
||||
process := exec.Command(a, b...)
|
||||
process.Dir = path
|
||||
process.Stderr = os.Stderr
|
||||
process.Stdin = os.Stdin
|
||||
process.Stdout = os.Stdout
|
||||
err := process.Run()
|
||||
if err != nil {
|
||||
log.Info("ExecCheck() err", err)
|
||||
return err
|
||||
}
|
||||
// log.Info("ExecCheck() nil")
|
||||
return nil
|
||||
}
|
||||
|
||||
func SudoRaw(c []string) {
|
||||
args := []string{"-S"}
|
||||
args = append(args, c...)
|
||||
|
|
Loading…
Reference in New Issue