MCPcopy Create free account
hub / github.com/astercloud/aster / buildFullCommand

Method buildFullCommand

pkg/tools/builtin/bash.go:347–367  ·  view source on GitHub ↗
(command string, environment map[string]string, shellType string)

Source from the content-addressed store, hash-verified

345}
346
347func (t *BashTool) buildFullCommand(command string, environment map[string]string, shellType string) string {
348 var parts []string
349
350 // 添加环境变量
351 for k, v := range environment {
352 parts = append(parts, fmt.Sprintf("export %s='%s'", k, strings.ReplaceAll(v, "'", `'"'"'`)))
353 }
354
355 // 添加命令
356 parts = append(parts, command)
357
358 // 根据shell类型构建
359 switch shellType {
360 case "sh":
361 return fmt.Sprintf("sh -c '%s'", strings.Join(parts, "; "))
362 case "zsh":
363 return fmt.Sprintf("zsh -c '%s'", strings.Join(parts, "; "))
364 default: // bash
365 return fmt.Sprintf("bash -c '%s'", strings.Join(parts, "; "))
366 }
367}
368
369func (t *BashTool) getCommandTimeout(cmd string) time.Duration {
370 // 根据命令类型调整超时时间

Callers 1

ExecuteMethod · 0.95

Calls 1

JoinMethod · 0.45

Tested by

no test coverage detected