| 1699 | } |
| 1700 | |
| 1701 | func runShellCommand(ctx context.Context, command, cwd string, timeout time.Duration) (int, string) { |
| 1702 | return runArgvCommand(ctx, bashpkg.ShellArgv(command, ""), cwd, timeout, command) |
| 1703 | } |
| 1704 | |
| 1705 | func runArgvCommand(ctx context.Context, argv []string, cwd string, timeout time.Duration, originalCommand string) (int, string) { |
| 1706 | if len(argv) == 0 { |
| 1707 | return -1, "Error executing command: empty argv" |
| 1708 | } |
| 1709 | if timeout <= 0 { |
| 1710 | return -1, fmt.Sprintf("Error: Command timed out after %ss.\n\nCommand: %s", formatPythonFloatSeconds(timeout), originalCommand) |
| 1711 | } |
| 1712 | cmdCtx, cancel := context.WithTimeout(ctx, timeout) |
| 1713 | defer cancel() |