mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 12:55:47 +02:00
platform specific shell usage
This commit is contained in:
parent
46fb4c5f0a
commit
a70753364c
1 changed files with 11 additions and 2 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -111,12 +112,20 @@ func mergeGitStatusFiles(oldGitFiles, newGitFiles []GitFile) []GitFile {
|
|||
return result
|
||||
}
|
||||
|
||||
func platformShell() (string, string) {
|
||||
if runtime.GOOS == "windows" {
|
||||
return "cmd", "/c"
|
||||
}
|
||||
return "sh", "-c"
|
||||
}
|
||||
|
||||
func runDirectCommand(command string) (string, error) {
|
||||
timeStart := time.Now()
|
||||
|
||||
commandLog(command)
|
||||
|
||||
shell, shellArg := platformShell()
|
||||
cmdOut, err := exec.
|
||||
Command("sh", "-c", command).
|
||||
Command(shell, shellArg, command).
|
||||
CombinedOutput()
|
||||
devLog("run direct command time for command: ", command, time.Now().Sub(timeStart))
|
||||
return sanitisedCommandOutput(cmdOut, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue