charmbracelet/crush · warning
empty command
Error message
empty command
What it means
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.
Source
Thrown at internal/ui/util/util.go:91
ClearStatusMsg struct{}
)
// IsEmpty checks if the [InfoMsg] is empty.
func (m InfoMsg) IsEmpty() bool {
var zero InfoMsg
return m == zero
}
// ExecShell parses a shell command string and executes it with exec.Command.
// Uses shell.Fields for proper handling of shell syntax like quotes and
// arguments while preserving TTY handling for terminal editors.
func ExecShell(ctx context.Context, cmdStr string, callback tea.ExecCallback) tea.Cmd {
fields, err := shell.Fields(cmdStr, nil)
if err != nil {
return ReportError(err)
}
if len(fields) == 0 {
return ReportError(errors.New("empty command"))
}
cmd := exec.CommandContext(ctx, fields[0], fields[1:]...)
return tea.ExecProcess(cmd, callback)
}
View on GitHub (pinned to 7944b8e522)
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
Example fix
// before
util.ExecShell(ctx, cmdStr, callback)
// after
if strings.TrimSpace(cmdStr) != "" {
cmds = append(cmds, util.ExecShell(ctx, cmdStr, callback))
} Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(cmdStr) == "" {
return
} Type guard
func hasCommand(s string) bool { return strings.TrimSpace(s) != "" } Try / catch
if err, ok := <-errCh; ok && err.Error() == "empty command" { /* skip */ } Prevention
- Never call ExecShell with empty or whitespace-only strings
- Check input fields count before dispatch
- Treat comment-only input as empty
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Crush crashed. If metrics are enabled, we were notified abou
- configuration not found
- agent configuration not found
- session ID is required for executing shell command
- error starting background shell: %w
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/af545f47ee908484.
Report an issue: GitHub.