1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-23 00:39:13 +02:00

avoid useless allocation

This commit is contained in:
Anthony HAMON
2018-08-21 21:48:42 +02:00
parent 32f4d09e89
commit 7a74bc504b

View File

@ -41,8 +41,10 @@ func (c *OSCommand) RunCommandWithOutput(command string) (string, error) {
c.Log.WithField("command", command).Info("RunCommand")
splitCmd := str.ToArgv(command)
c.Log.Info(splitCmd)
cmdOut, err := exec.Command(splitCmd[0], splitCmd[1:]...).CombinedOutput()
return sanitisedCommandOutput(cmdOut, err)
return sanitisedCommandOutput(
exec.Command(splitCmd[0], splitCmd[1:]...).CombinedOutput(),
)
}
// RunCommand runs a command and just returns the error
@ -57,10 +59,11 @@ func (c *OSCommand) RunDirectCommand(command string) (string, error) {
args := str.ToArgv(c.Platform.shellArg + " " + command)
c.Log.Info(spew.Sdump(args))
cmdOut, err := exec.
Command(c.Platform.shell, args...).
CombinedOutput()
return sanitisedCommandOutput(cmdOut, err)
return sanitisedCommandOutput(
exec.
Command(c.Platform.shell, args...).
CombinedOutput(),
)
}
func sanitisedCommandOutput(output []byte, err error) (string, error) {