diff options
Diffstat (limited to 'pkg/commands/oscommands/os.go')
-rw-r--r-- | pkg/commands/oscommands/os.go | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go index f3df3956f..b6f018af5 100644 --- a/pkg/commands/oscommands/os.go +++ b/pkg/commands/oscommands/os.go @@ -12,6 +12,7 @@ import ( "github.com/go-errors/errors" "github.com/atotto/clipboard" + "github.com/jesseduffield/generics/slices" "github.com/jesseduffield/lazygit/pkg/common" "github.com/jesseduffield/lazygit/pkg/utils" ) @@ -173,15 +174,11 @@ func (c *OSCommand) FileExists(path string) (bool, error) { // PipeCommands runs a heap of commands and pipes their inputs/outputs together like A | B | C func (c *OSCommand) PipeCommands(commandStrings ...string) error { - cmds := make([]*exec.Cmd, len(commandStrings)) - logCmdStr := "" - for i, str := range commandStrings { - if i > 0 { - logCmdStr += " | " - } - logCmdStr += str - cmds[i] = c.Cmd.New(str).GetCmd() - } + cmds := slices.Map(commandStrings, func(cmdString string) *exec.Cmd { + return c.Cmd.New(cmdString).GetCmd() + }) + + logCmdStr := strings.Join(commandStrings, " | ") c.LogCommand(logCmdStr, true) for i := 0; i < len(cmds)-1; i++ { |