minitor-go/util.go
Ian Fijolek 3226be69e7
All checks were successful
continuous-integration/drone/push Build is passing
Fix issue with shell commands containing "<>" and unecessary (and poor) escaping
2020-01-07 10:37:53 -08:00

27 lines
572 B
Go

package main
import (
"os/exec"
"strings"
)
// ShellCommand takes a string and executes it as a command using `sh`
func ShellCommand(command string) *exec.Cmd {
shellCommand := []string{"sh", "-c", strings.TrimSpace(command)}
//log.Printf("Shell command: %v", shellCommand)
return exec.Command(shellCommand[0], shellCommand[1:]...)
}
// EqualSliceString checks if two string slices are equivalent
func EqualSliceString(a, b []string) bool {
if len(a) != len(b) {
return false
}
for i, val := range a {
if val != b[i] {
return false
}
}
return true
}