mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-19 00:28:03 +02:00
platform specific shell usage
This commit is contained in:
@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -111,12 +112,20 @@ func mergeGitStatusFiles(oldGitFiles, newGitFiles []GitFile) []GitFile {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func platformShell() (string, string) {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
return "cmd", "/c"
|
||||||
|
}
|
||||||
|
return "sh", "-c"
|
||||||
|
}
|
||||||
|
|
||||||
func runDirectCommand(command string) (string, error) {
|
func runDirectCommand(command string) (string, error) {
|
||||||
timeStart := time.Now()
|
timeStart := time.Now()
|
||||||
|
|
||||||
commandLog(command)
|
commandLog(command)
|
||||||
|
|
||||||
|
shell, shellArg := platformShell()
|
||||||
cmdOut, err := exec.
|
cmdOut, err := exec.
|
||||||
Command("sh", "-c", command).
|
Command(shell, shellArg, command).
|
||||||
CombinedOutput()
|
CombinedOutput()
|
||||||
devLog("run direct command time for command: ", command, time.Now().Sub(timeStart))
|
devLog("run direct command time for command: ", command, time.Now().Sub(timeStart))
|
||||||
return sanitisedCommandOutput(cmdOut, err)
|
return sanitisedCommandOutput(cmdOut, err)
|
||||||
|
Reference in New Issue
Block a user