{"record":{"id":"af545f47ee908484","repo":"charmbracelet/crush","slug":"empty-command","errorCode":null,"errorMessage":"empty command","messagePattern":"empty command","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/ui/util/util.go","lineNumber":91,"sourceCode":"\tClearStatusMsg struct{}\n)\n\n// IsEmpty checks if the [InfoMsg] is empty.\nfunc (m InfoMsg) IsEmpty() bool {\n\tvar zero InfoMsg\n\treturn m == zero\n}\n\n// ExecShell parses a shell command string and executes it with exec.Command.\n// Uses shell.Fields for proper handling of shell syntax like quotes and\n// arguments while preserving TTY handling for terminal editors.\nfunc ExecShell(ctx context.Context, cmdStr string, callback tea.ExecCallback) tea.Cmd {\n\tfields, err := shell.Fields(cmdStr, nil)\n\tif err != nil {\n\t\treturn ReportError(err)\n\t}\n\tif len(fields) == 0 {\n\t\treturn ReportError(errors.New(\"empty command\"))\n\t}\n\n\tcmd := exec.CommandContext(ctx, fields[0], fields[1:]...)\n\treturn tea.ExecProcess(cmd, callback)\n}\n","sourceCodeStart":73,"sourceCodeEnd":97,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/ui/util/util.go#L73-L97","documentation":"ExecShell in internal/ui/util splits the command string with shell.Fields; if splitting succeeds but yields zero fields (i.e. the command string is empty or only whitespace/comments), it refuses to exec and reports this error rather than calling exec with no binary.","triggerScenarios":"Calling ExecShell with cmdStr == \"\" or a whitespace-only string; also when shell.Fields reduces the input to nothing (e.g. a string that is only a shell comment).","commonSituations":"TUI commands executing a user/editor-supplied command buffer that is empty; variables expanding to empty before the call; copying a command but pasting only whitespace.","solutions":["Guard the caller: skip ExecShell when the trimmed command string is empty","Show a validation message to the user instead of dispatching an empty command","Trim and non-empty check the input at the UI boundary"],"exampleFix":"// before\nutil.ExecShell(ctx, cmdStr, callback)\n// after\nif strings.TrimSpace(cmdStr) != \"\" {\n\tcmds = append(cmds, util.ExecShell(ctx, cmdStr, callback))\n}","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(cmdStr) == \"\" {\n\treturn\n}","typeGuard":"func hasCommand(s string) bool { return strings.TrimSpace(s) != \"\" }","tryCatchPattern":"if err, ok := <-errCh; ok && err.Error() == \"empty command\" { /* skip */ }","preventionTips":["Never call ExecShell with empty or whitespace-only strings","Check input fields count before dispatch","Treat comment-only input as empty"],"tags":["shell","tui","validation","go"],"backgroundTag":"empty-command-input","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}