2019-09-21 15:03:26 -07:00
|
|
|
package main
|
|
|
|
|
2019-10-01 08:26:07 -07:00
|
|
|
import (
|
|
|
|
"os/exec"
|
|
|
|
"strings"
|
|
|
|
)
|
2019-09-21 15:03:26 -07:00
|
|
|
|
2019-10-02 16:09:11 -07:00
|
|
|
// ShellCommand takes a string and executes it as a command using `sh`
|
2019-10-01 08:26:07 -07:00
|
|
|
func ShellCommand(command string) *exec.Cmd {
|
2020-01-07 10:37:53 -08:00
|
|
|
shellCommand := []string{"sh", "-c", strings.TrimSpace(command)}
|
2021-05-10 20:12:18 -07:00
|
|
|
|
2019-10-01 08:26:07 -07:00
|
|
|
return exec.Command(shellCommand[0], shellCommand[1:]...)
|
|
|
|
}
|
2019-10-04 14:47:38 -07:00
|
|
|
|
|
|
|
// EqualSliceString checks if two string slices are equivalent
|
|
|
|
func EqualSliceString(a, b []string) bool {
|
|
|
|
if len(a) != len(b) {
|
|
|
|
return false
|
|
|
|
}
|
2021-05-10 21:00:58 -07:00
|
|
|
|
2019-10-04 14:47:38 -07:00
|
|
|
for i, val := range a {
|
|
|
|
if val != b[i] {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
2021-05-10 21:00:58 -07:00
|
|
|
|
2019-10-04 14:47:38 -07:00
|
|
|
return true
|
|
|
|
}
|