Skip to content

Commit a286e4f

Browse files
committed
refactor: use _comp_compgen_help with post-filter
1 parent e06a482 commit a286e4f

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

completions/badblocks

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ _comp_cmd_badblocks()
1717

1818
if [[ $cur == -* ]]; then
1919
# Filter out -w (dangerous) and -X (internal use)
20-
COMPREPLY=($(compgen -X '-[wX]' -W '$(_parse_usage "$1")' -- "$cur"))
20+
_comp_compgen -R usage
21+
((${#COMPREPLY[@]})) &&
22+
_comp_compgen -- -X '-[wX]' -W '"${COMPREPLY[@]}"'
2123
return
2224
fi
2325

completions/dnssec-keygen

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ _comp_cmd_dnssec_keygen()
3737
esac
3838

3939
if [[ $cur == -* ]]; then
40-
COMPREPLY=($(compgen -W '$(_parse_help "$1" | \
41-
command sed -e "s/:\$//")' -- "$cur"))
40+
_comp_compgen -R help
41+
((${#COMPREPLY[@]})) &&
42+
_comp_compgen -- -W '$(printf "%s\n" "${COMPREPLY[@]}" |
43+
command sed -e "s/:\$//")'
4244
return
4345
fi
4446
} &&

completions/links

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ _comp_cmd_links()
8080
esac
8181

8282
if [[ $cur == -* ]]; then
83-
COMPREPLY=($(compgen -W '$(_parse_help "$1" |
84-
command grep -vF -- "->")' -- "$cur"))
83+
_comp_compgen -R help
84+
((${#COMPREPLY[@]})) &&
85+
_comp_compgen -- -W '$(printf "%s\n" "${COMPREPLY[@]}" |
86+
command grep -vF -- "->")'
8587
return
8688
fi
8789

completions/zopfli

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ _comp_cmd_zopfli()
1212
esac
1313

1414
if [[ $cur == -* ]]; then
15-
COMPREPLY=($(compgen -W \
16-
'$(_parse_help "$1" -h | command sed -e "s/#$//")' -- "$cur"))
15+
_comp_compgen -R help -- -h
16+
((${#COMPREPLY[@]})) &&
17+
_comp_compgen -- -W '$(printf "%s\n" "${COMPREPLY[@]}" |
18+
command sed -e "s/#$//")' -- "$cur"
1719
[[ ${COMPREPLY-} == --i ]] && compopt -o nospace
1820
return
1921
fi

0 commit comments

Comments
 (0)