#10710: fix(cli): filter empty flags in bash completion generation
cli
stale
Cluster:
Zsh and PowerShell Completion Fixes
## Summary
- `options.flags.split(" ")[0]` can produce empty strings when an option has empty/whitespace-only flags
- Empty tokens in the `opts` variable cause spurious bash completion matches
- Add `.filter(Boolean)` at both top-level and subcommand levels
## Test plan
- [x] Generated bash completion script no longer contains consecutive spaces from empty flags
- [x] All existing tests pass
Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
- Updates bash completion generation to avoid emitting empty option tokens when an option’s `flags` string is empty/whitespace-only.
- Applies `.filter(Boolean)` after mapping `Option.flags.split(" ")[0]` for both the root command and subcommands.
- Resulting `opts` word list used by `compgen -W` no longer contains empty entries that create spurious matches in bash completion.
- Change is localized to `src/cli/completion-cli.ts` and does not alter zsh/powershell/fish completion code paths.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Change is narrowly scoped to bash completion generation and only filters out empty flag tokens; it preserves existing behavior for valid flags and avoids creating invalid completion candidates.
- No files require special attention
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#11165: fix(cli): filter empty flags in zsh and PowerShell nested completion
by Yida-Dev · 2026-02-07
92.3%
#10723: fix(cli): filter empty flags in PowerShell completion generation
by Yida-Dev · 2026-02-06
91.5%
#17437: fix(completion): avoid rc=1 for optionless zsh leaf commands
by ephelia-ai · 2026-02-15
76.9%
#17680: perf(cli): skip plugin loading during completion generation
by mcrolly · 2026-02-16
75.8%
#13840: perf(cli): skip plugin loading during completion generation
by lailoo · 2026-02-11
75.2%
#9148: Fix: Speed up shell completion generation from ~4.6s to <200ms
by vishaltandale00 · 2026-02-04
74.5%
#12308: fix(cli): redirect log output to stderr during completion script ge...
by mcaxtr · 2026-02-09
73.2%
#6382: fix(cli): silence Powerlevel10k Zsh warning from completion script
by dungngo4520 · 2026-02-01
72.9%
#22488: fix(cli): redirect plugin logs to stderr during completion
by pierreeurope · 2026-02-21
72.7%
#9158: perf(completion): add fast path for cached completions
by gavinbmoore · 2026-02-04
72.3%