MCPcopy Create free account
hub / github.com/celer-pkg/celer / buildNativeCommand

Method buildNativeCommand

pkgs/cmd/exec_windows.go:94–116  ·  view source on GitHub ↗

buildNativeCommand constructs a command to run in native Windows environment.

(displayCmd *string)

Source from the content-addressed store, hash-verified

92
93// buildNativeCommand constructs a command to run in native Windows environment.
94func (e *executor) buildNativeCommand(displayCmd *string) *exec.Cmd {
95 *displayCmd = e.command
96 if len(e.args) > 0 {
97 *displayCmd += " " + strings.Join(e.args, " ")
98 }
99
100 var cmd *exec.Cmd
101
102 if len(e.args) == 0 {
103 // Command without arguments: wrap in cmd.exe /c for shell features
104 cmd = exec.Command("cmd")
105 cmd.SysProcAttr = &syscall.SysProcAttr{
106 CmdLine: fmt.Sprintf(`/c %s`, e.command),
107 HideWindow: true, // Hide console window for native commands
108 }
109 } else {
110 // Command with arguments: direct execution (safer, no shell parsing)
111 cmd = exec.Command(e.command, e.args...)
112 }
113
114 cmd.Env = os.Environ()
115 return cmd
116}

Callers 4

doExecuteMethod · 0.95

Calls 2

SprintfMethod · 0.80
CommandMethod · 0.65