MCPcopy Create free account
hub / github.com/Azure/ARO-HCP / ExecCommandString

Function ExecCommandString

tooling/hcpctl/pkg/shell/shell.go:82–94  ·  view source on GitHub ↗

ExecCommandString executes a command string directly with KUBECONFIG environment set. This is a convenience function that parses a command string and calls ExecCommand. The command string is parsed using shell-like parsing with support for quoted arguments. This function blocks until the command e

(ctx context.Context, config *Config, commandStr string, stopCh chan struct{}, stopOnce *sync.Once)

Source from the content-addressed store, hash-verified

80//
81// This function blocks until the command exits or the context is cancelled.
82func ExecCommandString(ctx context.Context, config *Config, commandStr string, stopCh chan struct{}, stopOnce *sync.Once) error {
83 command, err := shlex.Split(commandStr)
84 if err != nil {
85 stopOnce.Do(func() { close(stopCh) })
86 return fmt.Errorf("failed to parse command: %w", err)
87 }
88
89 if len(command) == 0 {
90 stopOnce.Do(func() { close(stopCh) })
91 return fmt.Errorf("empty command provided")
92 }
93 return ExecCommand(ctx, config, command, stopCh, stopOnce)
94}
95
96// spawnShell is the internal implementation that spawns an interactive shell
97// with KUBECONFIG environment set and custom prompt configuration.

Callers

nothing calls this directly

Calls 2

ExecCommandFunction · 0.85
DoMethod · 0.65

Tested by

no test coverage detected