diff --git a/luci.config.toml b/luci.config.toml new file mode 100755 index 0000000..89553d6 --- /dev/null +++ b/luci.config.toml @@ -0,0 +1,12 @@ + +title = "Hello World!" +description = "Luci config hello world example." + +[bash.run] +example = "echo Hello World!" + +[zshell.run] +example = "echo Hello World!" + +[bat.run] +example = "echo Hello World!" diff --git a/utils/exec.go b/utils/exec.go index d5dcc12..0989c26 100644 --- a/utils/exec.go +++ b/utils/exec.go @@ -1,9 +1,7 @@ package utils import ( - "bufio" - "fmt" - "log" + "os" "os/exec" "runtime" "strings" @@ -86,29 +84,9 @@ func execAction(action any) bool { } func execCmd(cmd *exec.Cmd) { - pipe, err := cmd.StdoutPipe() - if err != nil { - log.Fatal(err) - } - scanner := bufio.NewScanner(pipe) - - err = cmd.Start() - if err != nil { - log.Fatal(err) - } - - for scanner.Scan() { - m := scanner.Text() - fmt.Println(m) - } - - if err := scanner.Err(); err != nil { - log.Fatal(err) - } - - // Wait for the command to finish after reading all output - err = cmd.Wait() - if err != nil { - log.Fatal(err) - } + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + Must(cmd.Start()) + Must(cmd.Wait()) } diff --git a/utils/utils.go b/utils/utils.go index 05e820e..8335545 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -18,3 +18,9 @@ func GetShellType() types.ShellType { return types.Unknown } } + +func Must(err error) { + if err != nil { + panic(err) + } +}