cmd is the main logic for executing simple commands
(ctx context.Context, args []string, st *ShellState)
| 314 | |
| 315 | // cmd is the main logic for executing simple commands |
| 316 | func (h *shellCallHandler) cmd(ctx context.Context, args []string, st *ShellState) (*ShellState, error) { |
| 317 | c, a := args[0], args[1:] |
| 318 | |
| 319 | // First command in pipeline: e.g., `cmd1 | cmd2 | cmd3` |
| 320 | if st == nil { |
| 321 | return h.entrypointCall(ctx, c, a) |
| 322 | } |
| 323 | |
| 324 | if h.Debug() { |
| 325 | shellDebug(ctx, "Stdin", c, a, st) |
| 326 | } |
| 327 | |
| 328 | builtin, err := h.BuiltinCommand(c) |
| 329 | if err != nil { |
| 330 | return nil, err |
| 331 | } |
| 332 | if builtin != nil { |
| 333 | return nil, builtin.Execute(ctx, h, a, st) |
| 334 | } |
| 335 | |
| 336 | // module or core function call |
| 337 | return h.functionCall(ctx, st, c, a) |
| 338 | } |
| 339 | |
| 340 | // entrypointCall is executed when it's the first command in a pipeline |
| 341 | func (h *shellCallHandler) entrypointCall(ctx context.Context, cmd string, args []string) (*ShellState, error) { |
no test coverage detected