diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-02 12:55:50 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-02 13:15:07 +1100 |
commit | 8901d11674b20b59102d24ad94a394dde0e0977b (patch) | |
tree | 29a290398ce513b0be18666c61cdfc47672e6821 /pkg/commands/oscommands | |
parent | 8b7f7cbc30f2ded008ff2b123664dc493b7527b5 (diff) |
fix merge conflict cat issue on windows
Diffstat (limited to 'pkg/commands/oscommands')
-rw-r--r-- | pkg/commands/oscommands/os.go | 14 | ||||
-rw-r--r-- | pkg/commands/oscommands/os_default_platform.go | 2 | ||||
-rw-r--r-- | pkg/commands/oscommands/os_windows.go | 2 |
3 files changed, 15 insertions, 3 deletions
diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go index 8eaff53d2..bd1102d22 100644 --- a/pkg/commands/oscommands/os.go +++ b/pkg/commands/oscommands/os.go @@ -24,7 +24,7 @@ import ( // Platform stores the os state type Platform struct { OS string - CatCmd string + CatCmd []string Shell string ShellArg string EscapedQuote string @@ -100,6 +100,18 @@ func (c *OSCommand) RunCommandWithOutput(formatString string, formatArgs ...inte return output, err } +func (c *OSCommand) CatFile(filename string) (string, error) { + arr := append(c.Platform.CatCmd, filename) + cmdStr := strings.Join(arr, " ") + c.Log.WithField("command", cmdStr).Info("Cat") + cmd := c.Command(arr[0], arr[1:]...) + output, err := sanitisedCommandOutput(cmd.CombinedOutput()) + if err != nil { + c.Log.WithField("command", cmdStr).Error(err) + } + return output, err +} + // RunExecutableWithOutput runs an executable file and returns its output func (c *OSCommand) RunExecutableWithOutput(cmd *exec.Cmd) (string, error) { c.BeforeExecuteCmd(cmd) diff --git a/pkg/commands/oscommands/os_default_platform.go b/pkg/commands/oscommands/os_default_platform.go index 80ef1aebd..3fb579eec 100644 --- a/pkg/commands/oscommands/os_default_platform.go +++ b/pkg/commands/oscommands/os_default_platform.go @@ -9,7 +9,7 @@ import ( func getPlatform() *Platform { return &Platform{ OS: runtime.GOOS, - CatCmd: "cat", + CatCmd: []string{"cat"}, Shell: "bash", ShellArg: "-c", EscapedQuote: `"`, diff --git a/pkg/commands/oscommands/os_windows.go b/pkg/commands/oscommands/os_windows.go index 3e86c803f..206d50433 100644 --- a/pkg/commands/oscommands/os_windows.go +++ b/pkg/commands/oscommands/os_windows.go @@ -3,7 +3,7 @@ package oscommands func getPlatform() *Platform { return &Platform{ OS: "windows", - CatCmd: "cmd /c type", + CatCmd: []string{"cmd", "/c", "type"}, Shell: "cmd", ShellArg: "/c", EscapedQuote: `\"`, |