From d7fc3e1f6c789d8749fbc3bd7838d1caeb88a03d Mon Sep 17 00:00:00 2001 From: aram price Date: Thu, 12 Dec 2024 15:25:12 -0800 Subject: [PATCH] Consolidate identical `newExecCmd()` implementations These two implementations existed in the `unix` and `windows` variants of `exec_cmd_runner`. Perhaps they differed in the past but at present they are identical. This consolidates the two implementations into `exec_cmd_runner.go` from the respective OS-specific files. --- system/exec_cmd_runner.go | 4 ++++ system/exec_cmd_runner_unix.go | 6 +----- system/exec_cmd_runner_windows.go | 5 ----- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/system/exec_cmd_runner.go b/system/exec_cmd_runner.go index 6cab6558..a6ec3e05 100644 --- a/system/exec_cmd_runner.go +++ b/system/exec_cmd_runner.go @@ -92,3 +92,7 @@ func (r execCmdRunner) buildComplexCommand(cmd Command) *exec.Cmd { return execCmd } + +func newExecCmd(name string, args ...string) *exec.Cmd { + return exec.Command(name, args...) +} diff --git a/system/exec_cmd_runner_unix.go b/system/exec_cmd_runner_unix.go index e049f11a..5096aa45 100644 --- a/system/exec_cmd_runner_unix.go +++ b/system/exec_cmd_runner_unix.go @@ -1,16 +1,12 @@ +//go:build !windows // +build !windows package system import ( - "os/exec" "strings" ) -func newExecCmd(name string, args ...string) *exec.Cmd { - return exec.Command(name, args...) -} - // mergeEnv merges system and command environments variables. Command variables // override any system variable with the same key. func mergeEnv(sysEnv []string, cmdEnv map[string]string) []string { diff --git a/system/exec_cmd_runner_windows.go b/system/exec_cmd_runner_windows.go index 5b057470..bcd6247b 100644 --- a/system/exec_cmd_runner_windows.go +++ b/system/exec_cmd_runner_windows.go @@ -1,15 +1,10 @@ package system import ( - "os/exec" "sort" "strings" ) -func newExecCmd(name string, args ...string) *exec.Cmd { - return exec.Command(name, args...) -} - // mergeEnv case-insensitive merge of system and command environments variables. // Command variables override any system variable with the same key. func mergeEnv(sysEnv []string, cmdEnv map[string]string) []string {