Skip to content

Commit

Permalink
fix: use _comp_split while keeping filtering by $cur
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jan 14, 2024
1 parent a00ee19 commit 509e642
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
8 changes: 4 additions & 4 deletions completions/_yum
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ _comp_cmd_yum__list()
if [[ $1 == all ]]; then
# Try to strip in between headings like "Available Packages"
# This will obviously only work for English :P
COMPREPLY=($(yum -d 0 -C list "$1" "$cur*" 2>/dev/null |
_comp_split COMPREPLY "$(yum -d 0 -C list "$1" "$cur*" 2>/dev/null |
command sed -ne '/^Available /d' -e '/^Installed /d' \
-e '/^Updated /d' -e 's/[[:space:]].*//p'))
-e '/^Updated /d' -e 's/[[:space:]].*//p')"
else
# Drop first line (e.g. "Updated Packages")
COMPREPLY=($(yum -d 0 -C list "$1" "$cur*" 2>/dev/null |
command sed -ne 1d -e 's/[[:space:]].*//p'))
_comp_split COMPREPLY "$(yum -d 0 -C list "$1" "$cur*" 2>/dev/null |
command sed -ne 1d -e 's/[[:space:]].*//p')"
fi
}

Expand Down
4 changes: 2 additions & 2 deletions completions/cpan2dist
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ _comp_cmd_cpan2dist()
[[ -d $dir && -r "$dir/02packages.details.txt.gz" ]] &&
packagelist="$dir/02packages.details.txt.gz"
done
[[ $packagelist ]] && COMPREPLY=($(zgrep "^${cur//-/::}" \
[[ $packagelist ]] && _comp_split COMPREPLY "$(zgrep "^${cur//-/::}" \
"$packagelist" 2>/dev/null | _comp_awk '{print $1}' |
command sed -e 's/::/-/g'))
command sed -e 's/::/-/g')"
fi
} &&
complete -F _comp_cmd_cpan2dist -o default cpan2dist
Expand Down
5 changes: 2 additions & 3 deletions completions/make
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,10 @@ _comp_cmd_make()
# mode=-d # display-only mode
# fi

local IFS=$' \t\n'
COMPREPLY=($(LC_ALL=C \
_comp_split COMPREPLY "$(LC_ALL=C \
$1 -npq __BASH_MAKE_COMPLETION__=1 \
${makef+"${makef[@]}"} "${makef_dir[@]}" .DEFAULT 2>/dev/null |
_comp_cmd_make__extract_targets "$mode" "$cur"))
_comp_cmd_make__extract_targets "$mode" "$cur")"

_comp_cmd_make__truncate_non_unique_paths

Expand Down
5 changes: 2 additions & 3 deletions completions/vncviewer
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,13 @@ _comp_cmd_xvnc4viewer()
WMDecorationWidth ZlibLevel)
[[ $cur == --* ]] && dash=-- || dash=-

local IFS=$' \t\n'
COMPREPLY=($(
_comp_split COMPREPLY "$(
shopt -s nocasematch
local option
for option in "${options[@]}"; do
[[ $dash$option == "$cur"* ]] && printf '%s\n' "$dash$option"
done
))
)"
else
_comp_compgen_known_hosts -- "$cur"
fi
Expand Down

0 comments on commit 509e642

Please sign in to comment.