mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-27 12:32:37 +02:00
Revert commits related to using an interactive shell for running shell commands
This reverts commits f28b6f439d, dbd407c01d, 5fac40c129, and 5a3049485c.
This commit is contained in:
parent
959f932ddd
commit
4e5e21f946
@ -38,10 +38,6 @@ func (self *gitCmdObjBuilder) NewShell(cmdStr string) oscommands.ICmdObj {
|
|||||||
return self.innerBuilder.NewShell(cmdStr).AddEnvVars(defaultEnvVar)
|
return self.innerBuilder.NewShell(cmdStr).AddEnvVars(defaultEnvVar)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *gitCmdObjBuilder) NewInteractiveShell(cmdStr string) oscommands.ICmdObj {
|
|
||||||
return self.innerBuilder.NewInteractiveShell(cmdStr).AddEnvVars(defaultEnvVar)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *gitCmdObjBuilder) Quote(str string) string {
|
func (self *gitCmdObjBuilder) Quote(str string) string {
|
||||||
return self.innerBuilder.Quote(str)
|
return self.innerBuilder.Quote(str)
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,6 @@ type ICmdObjBuilder interface {
|
|||||||
New(args []string) ICmdObj
|
New(args []string) ICmdObj
|
||||||
// NewShell takes a string like `git commit` and returns an executable shell command for it e.g. `sh -c 'git commit'`
|
// NewShell takes a string like `git commit` and returns an executable shell command for it e.g. `sh -c 'git commit'`
|
||||||
NewShell(commandStr string) ICmdObj
|
NewShell(commandStr string) ICmdObj
|
||||||
// Like NewShell, but uses the user's shell rather than "bash", and passes -i to it
|
|
||||||
NewInteractiveShell(commandStr string) ICmdObj
|
|
||||||
// Quote wraps a string in quotes with any necessary escaping applied. The reason for bundling this up with the other methods in this interface is that we basically always need to make use of this when creating new command objects.
|
// Quote wraps a string in quotes with any necessary escaping applied. The reason for bundling this up with the other methods in this interface is that we basically always need to make use of this when creating new command objects.
|
||||||
Quote(str string) string
|
Quote(str string) string
|
||||||
}
|
}
|
||||||
@ -51,13 +49,6 @@ func (self *CmdObjBuilder) NewShell(commandStr string) ICmdObj {
|
|||||||
return self.New(cmdArgs)
|
return self.New(cmdArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CmdObjBuilder) NewInteractiveShell(commandStr string) ICmdObj {
|
|
||||||
quotedCommand := self.quotedCommandString(commandStr + self.platform.InteractiveShellExit)
|
|
||||||
cmdArgs := str.ToArgv(fmt.Sprintf("%s %s %s %s", self.platform.InteractiveShell, self.platform.InteractiveShellArg, self.platform.ShellArg, quotedCommand))
|
|
||||||
|
|
||||||
return self.New(cmdArgs)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *CmdObjBuilder) quotedCommandString(commandStr string) string {
|
func (self *CmdObjBuilder) quotedCommandString(commandStr string) string {
|
||||||
// Windows does not seem to like quotes around the command
|
// Windows does not seem to like quotes around the command
|
||||||
if self.platform.OS == "windows" {
|
if self.platform.OS == "windows" {
|
||||||
|
@ -51,14 +51,11 @@ func NewDummyCmdObjBuilder(runner ICmdObjRunner) *CmdObjBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var dummyPlatform = &Platform{
|
var dummyPlatform = &Platform{
|
||||||
OS: "darwin",
|
OS: "darwin",
|
||||||
Shell: "bash",
|
Shell: "bash",
|
||||||
InteractiveShell: "bash",
|
ShellArg: "-c",
|
||||||
ShellArg: "-c",
|
OpenCommand: "open {{filename}}",
|
||||||
InteractiveShellArg: "-i",
|
OpenLinkCommand: "open {{link}}",
|
||||||
InteractiveShellExit: "; exit $?",
|
|
||||||
OpenCommand: "open {{filename}}",
|
|
||||||
OpenLinkCommand: "open {{link}}",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDummyOSCommandWithRunner(runner *FakeCmdObjRunner) *OSCommand {
|
func NewDummyOSCommandWithRunner(runner *FakeCmdObjRunner) *OSCommand {
|
||||||
|
@ -35,14 +35,11 @@ type OSCommand struct {
|
|||||||
|
|
||||||
// Platform stores the os state
|
// Platform stores the os state
|
||||||
type Platform struct {
|
type Platform struct {
|
||||||
OS string
|
OS string
|
||||||
Shell string
|
Shell string
|
||||||
InteractiveShell string
|
ShellArg string
|
||||||
ShellArg string
|
OpenCommand string
|
||||||
InteractiveShellArg string
|
OpenLinkCommand string
|
||||||
InteractiveShellExit string
|
|
||||||
OpenCommand string
|
|
||||||
OpenLinkCommand string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewOSCommand os command runner
|
// NewOSCommand os command runner
|
||||||
|
@ -4,42 +4,15 @@
|
|||||||
package oscommands
|
package oscommands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetPlatform() *Platform {
|
func GetPlatform() *Platform {
|
||||||
shell := getUserShell()
|
|
||||||
|
|
||||||
interactiveShell := shell
|
|
||||||
interactiveShellArg := "-i"
|
|
||||||
interactiveShellExit := "; exit $?"
|
|
||||||
|
|
||||||
if strings.HasSuffix(shell, "fish") {
|
|
||||||
interactiveShellExit = "; exit $status"
|
|
||||||
} else if !(strings.HasSuffix(shell, "bash") || strings.HasSuffix(shell, "zsh")) {
|
|
||||||
interactiveShell = "bash"
|
|
||||||
interactiveShellArg = ""
|
|
||||||
interactiveShellExit = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
return &Platform{
|
return &Platform{
|
||||||
OS: runtime.GOOS,
|
OS: runtime.GOOS,
|
||||||
Shell: "bash",
|
Shell: "bash",
|
||||||
InteractiveShell: interactiveShell,
|
ShellArg: "-c",
|
||||||
ShellArg: "-c",
|
OpenCommand: "open {{filename}}",
|
||||||
InteractiveShellArg: interactiveShellArg,
|
OpenLinkCommand: "open {{link}}",
|
||||||
InteractiveShellExit: interactiveShellExit,
|
|
||||||
OpenCommand: "open {{filename}}",
|
|
||||||
OpenLinkCommand: "open {{link}}",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUserShell() string {
|
|
||||||
if shell := os.Getenv("SHELL"); shell != "" {
|
|
||||||
return shell
|
|
||||||
}
|
|
||||||
|
|
||||||
return "bash"
|
|
||||||
}
|
|
||||||
|
@ -2,11 +2,8 @@ package oscommands
|
|||||||
|
|
||||||
func GetPlatform() *Platform {
|
func GetPlatform() *Platform {
|
||||||
return &Platform{
|
return &Platform{
|
||||||
OS: "windows",
|
OS: "windows",
|
||||||
Shell: "cmd",
|
Shell: "cmd",
|
||||||
InteractiveShell: "cmd",
|
ShellArg: "/c",
|
||||||
ShellArg: "/c",
|
|
||||||
InteractiveShellArg: "",
|
|
||||||
InteractiveShellExit: "",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ func (self *ShellCommandAction) Call() error {
|
|||||||
|
|
||||||
self.c.LogAction(self.c.Tr.Actions.CustomCommand)
|
self.c.LogAction(self.c.Tr.Actions.CustomCommand)
|
||||||
return self.c.RunSubprocessAndRefresh(
|
return self.c.RunSubprocessAndRefresh(
|
||||||
self.c.OS().Cmd.NewInteractiveShell(command),
|
self.c.OS().Cmd.NewShell(command),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
HandleDeleteSuggestion: func(index int) error {
|
HandleDeleteSuggestion: func(index int) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user