move some code, add message color for x25519 command

This commit is contained in:
yuzuki999
2023-06-02 08:45:22 +08:00
parent 138540cd16
commit 989b4ff13e
5 changed files with 18 additions and 14 deletions

25
common/exec/exec.go Normal file
View File

@@ -0,0 +1,25 @@
package exec
import (
"errors"
"os"
"os/exec"
)
func RunCommandByShell(cmd string) (string, error) {
e := exec.Command("bash", "-c", cmd)
out, err := e.CombinedOutput()
if errors.Unwrap(err) == exec.ErrNotFound {
e = exec.Command("sh", "-c", cmd)
out, err = e.CombinedOutput()
}
return string(out), err
}
func RunCommandStd(name string, args ...string) {
e := exec.Command(name, args...)
e.Stdout = os.Stdout
e.Stdin = os.Stdin
e.Stderr = os.Stderr
_ = e.Run()
}