Skip to content

Commit

Permalink
completions: don't complete subcommands unless prev is "flux"
Browse files Browse the repository at this point in the history
Problem: Unsupported subcommands in bash completions (i.e. those not
in the big case statement in _flux_core()) end up having the list
of subcommands again offered as suggestions to tab completion, e.g.
`flux perilog-run <tab>` offers the list of `flux` subcommands as
completions again. This is wrong.

Only complete subcommands when `flux` is the previous command.
  • Loading branch information
grondo committed Jun 14, 2024
1 parent 4a2acad commit 8a107f2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions etc/completions/flux.pre
Original file line number Diff line number Diff line change
Expand Up @@ -2133,6 +2133,9 @@ _flux_core()
COMPREPLY=( $(compgen -W "${cmds}" -- "$cur") )
;;
*)
# return with no suggestions for unknown subcommands:
[[ "$prev" != "flux" ]] && return

matched=f
COMPREPLY=( $(compgen -W "${cmds}" -- "$cur") )
;;
Expand All @@ -2144,6 +2147,7 @@ _flux_core()
if test "$matched" = "t" -a -z "$COMPREPLY" -a "$cur" = "$cmd"; then
COMPREPLY="$cur"
fi

return 0
}

Expand Down

0 comments on commit 8a107f2

Please sign in to comment.