Skip to content

Commit 4e5e21f

Browse files
committed
Revert commits related to using an interactive shell for running shell commands
This reverts commits f28b6f4, dbd407c, 5fac40c, and 5a30494.
1 parent 959f932 commit 4e5e21f

File tree

7 files changed

+19
-68
lines changed

7 files changed

+19
-68
lines changed

pkg/commands/git_cmd_obj_builder.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ func (self *gitCmdObjBuilder) NewShell(cmdStr string) oscommands.ICmdObj {
3838
return self.innerBuilder.NewShell(cmdStr).AddEnvVars(defaultEnvVar)
3939
}
4040

41-
func (self *gitCmdObjBuilder) NewInteractiveShell(cmdStr string) oscommands.ICmdObj {
42-
return self.innerBuilder.NewInteractiveShell(cmdStr).AddEnvVars(defaultEnvVar)
43-
}
44-
4541
func (self *gitCmdObjBuilder) Quote(str string) string {
4642
return self.innerBuilder.Quote(str)
4743
}

pkg/commands/oscommands/cmd_obj_builder.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ type ICmdObjBuilder interface {
1414
New(args []string) ICmdObj
1515
// NewShell takes a string like `git commit` and returns an executable shell command for it e.g. `sh -c 'git commit'`
1616
NewShell(commandStr string) ICmdObj
17-
// Like NewShell, but uses the user's shell rather than "bash", and passes -i to it
18-
NewInteractiveShell(commandStr string) ICmdObj
1917
// 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.
2018
Quote(str string) string
2119
}
@@ -51,13 +49,6 @@ func (self *CmdObjBuilder) NewShell(commandStr string) ICmdObj {
5149
return self.New(cmdArgs)
5250
}
5351

54-
func (self *CmdObjBuilder) NewInteractiveShell(commandStr string) ICmdObj {
55-
quotedCommand := self.quotedCommandString(commandStr + self.platform.InteractiveShellExit)
56-
cmdArgs := str.ToArgv(fmt.Sprintf("%s %s %s %s", self.platform.InteractiveShell, self.platform.InteractiveShellArg, self.platform.ShellArg, quotedCommand))
57-
58-
return self.New(cmdArgs)
59-
}
60-
6152
func (self *CmdObjBuilder) quotedCommandString(commandStr string) string {
6253
// Windows does not seem to like quotes around the command
6354
if self.platform.OS == "windows" {

pkg/commands/oscommands/dummies.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,11 @@ func NewDummyCmdObjBuilder(runner ICmdObjRunner) *CmdObjBuilder {
5151
}
5252

5353
var dummyPlatform = &Platform{
54-
OS: "darwin",
55-
Shell: "bash",
56-
InteractiveShell: "bash",
57-
ShellArg: "-c",
58-
InteractiveShellArg: "-i",
59-
InteractiveShellExit: "; exit $?",
60-
OpenCommand: "open {{filename}}",
61-
OpenLinkCommand: "open {{link}}",
54+
OS: "darwin",
55+
Shell: "bash",
56+
ShellArg: "-c",
57+
OpenCommand: "open {{filename}}",
58+
OpenLinkCommand: "open {{link}}",
6259
}
6360

6461
func NewDummyOSCommandWithRunner(runner *FakeCmdObjRunner) *OSCommand {

pkg/commands/oscommands/os.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,11 @@ type OSCommand struct {
3535

3636
// Platform stores the os state
3737
type Platform struct {
38-
OS string
39-
Shell string
40-
InteractiveShell string
41-
ShellArg string
42-
InteractiveShellArg string
43-
InteractiveShellExit string
44-
OpenCommand string
45-
OpenLinkCommand string
38+
OS string
39+
Shell string
40+
ShellArg string
41+
OpenCommand string
42+
OpenLinkCommand string
4643
}
4744

4845
// NewOSCommand os command runner

pkg/commands/oscommands/os_default_platform.go

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,15 @@
44
package oscommands
55

66
import (
7-
"os"
87
"runtime"
9-
"strings"
108
)
119

1210
func GetPlatform() *Platform {
13-
shell := getUserShell()
14-
15-
interactiveShell := shell
16-
interactiveShellArg := "-i"
17-
interactiveShellExit := "; exit $?"
18-
19-
if strings.HasSuffix(shell, "fish") {
20-
interactiveShellExit = "; exit $status"
21-
} else if !(strings.HasSuffix(shell, "bash") || strings.HasSuffix(shell, "zsh")) {
22-
interactiveShell = "bash"
23-
interactiveShellArg = ""
24-
interactiveShellExit = ""
25-
}
26-
2711
return &Platform{
28-
OS: runtime.GOOS,
29-
Shell: "bash",
30-
InteractiveShell: interactiveShell,
31-
ShellArg: "-c",
32-
InteractiveShellArg: interactiveShellArg,
33-
InteractiveShellExit: interactiveShellExit,
34-
OpenCommand: "open {{filename}}",
35-
OpenLinkCommand: "open {{link}}",
12+
OS: runtime.GOOS,
13+
Shell: "bash",
14+
ShellArg: "-c",
15+
OpenCommand: "open {{filename}}",
16+
OpenLinkCommand: "open {{link}}",
3617
}
3718
}
38-
39-
func getUserShell() string {
40-
if shell := os.Getenv("SHELL"); shell != "" {
41-
return shell
42-
}
43-
44-
return "bash"
45-
}

pkg/commands/oscommands/os_windows.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ package oscommands
22

33
func GetPlatform() *Platform {
44
return &Platform{
5-
OS: "windows",
6-
Shell: "cmd",
7-
InteractiveShell: "cmd",
8-
ShellArg: "/c",
9-
InteractiveShellArg: "",
10-
InteractiveShellExit: "",
5+
OS: "windows",
6+
Shell: "cmd",
7+
ShellArg: "/c",
118
}
129
}

pkg/gui/controllers/shell_command_action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (self *ShellCommandAction) Call() error {
3131

3232
self.c.LogAction(self.c.Tr.Actions.CustomCommand)
3333
return self.c.RunSubprocessAndRefresh(
34-
self.c.OS().Cmd.NewInteractiveShell(command),
34+
self.c.OS().Cmd.NewShell(command),
3535
)
3636
},
3737
HandleDeleteSuggestion: func(index int) error {

0 commit comments

Comments
 (0)