File tree Expand file tree Collapse file tree 14 files changed +37
-36
lines changed Expand file tree Collapse file tree 14 files changed +37
-36
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,9 @@ _comp_cmd_bzip2()
18
18
esac
19
19
20
20
if [[ $cur == -* ]]; then
21
- local helpopts= $( _parse_help " $1 " )
22
- COMPREPLY=( $( compgen -W " ${ helpopts//#/ } -2 -3 -4 -5 -6 -7 -8 -9 " \
23
- -- " $cur " ) )
21
+ local helpopts
22
+ _comp_compgen -Rv helpopts help
23
+ _comp_compgen -- -W ' ${helpopts[*]//#/} -{2..9} '
24
24
return
25
25
fi
26
26
Original file line number Diff line number Diff line change @@ -37,7 +37,8 @@ _comp_cmd_complete()
37
37
esac
38
38
39
39
if [[ $cur == -* ]]; then
40
- local -a opts=($( compgen -W ' $(_parse_usage help "-s $1")' -- " $cur " ) )
40
+ local -a opts
41
+ _comp_compgen -v opts usage -c help -s " $1 "
41
42
# -F, -C do not work the expected way with compgen
42
43
[[ $1 != * compgen ]] || opts=(" ${opts[@]// -[FC]/ } " )
43
44
_comp_compgen -- -W ' "${opts[@]}"' -X ' '
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ _comp_cmd_declare()
7
7
8
8
if [[ $cur == [-+]* ]]; then
9
9
local opts
10
- opts=( $( _parse_usage help " -s $1 " ) )
10
+ _comp_compgen -Rv opts usage -c help -s " $1 "
11
11
# Most options also have a '+' form.
12
12
# We'll exclude the ones that don't with compgen.
13
13
opts+=(${opts[*]/ -/ +} )
Original file line number Diff line number Diff line change @@ -221,20 +221,21 @@ _comp_cmd_gnokii()
221
221
esac
222
222
fi
223
223
224
- local all_cmd=" $( _parse_help " $1 " " --help all" ) "
224
+ local all_cmd
225
+ _comp_compgen -Rv all_cmd help -- --help all
225
226
226
227
# these 2 below are allowed in combination with others
227
228
local main_cmd
228
- _comp_split -l main_cmd " $( command sed -e ' /--config/d;/--phone/d ' -e \
229
- ' s/[][\(){}|^$*+?.]/\\&/g' <<< " $all_cmd " ) "
229
+ _comp_split -l main_cmd " $( printf ' %s\n ' " ${all_cmd[@]} " |
230
+ command sed -e ' /--config/d;/--phone/d; s/[][\(){}|^$*+?.]/\\&/g' ) "
230
231
# don't provide main command completions if one is
231
232
# already on the command line
232
233
local IFS=' |'
233
234
local regex_main_cmd=" (${main_cmd[*]} )($|[^_[:alnum:]])"
234
235
IFS=$' \t\n '
235
236
[[ $COMP_LINE =~ $regex_main_cmd ]] && return
236
237
237
- _comp_compgen -- -W " $ all_cmd"
238
+ _comp_compgen -- -W ' "${ all_cmd[@]}" '
238
239
} &&
239
240
complete -F _comp_cmd_gnokii gnokii
240
241
Original file line number Diff line number Diff line change @@ -6,9 +6,8 @@ _comp_cmd_id()
6
6
_comp_initialize -- " $@ " || return
7
7
8
8
if [[ $cur == -* ]]; then
9
- local opts=$( _parse_help " $1 " )
10
- [[ $opts ]] || opts=" -G -g -u" # POSIX fallback
11
- _comp_compgen -- -W " $opts "
9
+ _comp_compgen_help ||
10
+ _comp_compgen -- -W ' -G -g -u' # POSIX fallback
12
11
else
13
12
COMPREPLY=($( compgen -u " $cur " ) )
14
13
fi
Original file line number Diff line number Diff line change @@ -20,9 +20,8 @@ _comp_cmd_mktemp()
20
20
[[ $was_split ]] && return
21
21
22
22
if [[ $cur == -* ]]; then
23
- local opts=$( _parse_help " $1 " )
24
- [[ $opts ]] || opts=" -d -u -q -p -t" # non-GNU fallback
25
- _comp_compgen -- -W " $opts "
23
+ _comp_compgen_help ||
24
+ _comp_compgen -- -W ' -d -u -q -p -t' # non-GNU fallback
26
25
[[ ${COMPREPLY-} == * = ]] && compopt -o nospace
27
26
fi
28
27
} &&
Original file line number Diff line number Diff line change @@ -78,10 +78,8 @@ _comp_cmd_mysql()
78
78
79
79
case $cur in
80
80
--* )
81
- local help=$( _parse_help " $1 " )
82
- help+=" --skip-comments --skip-ssl"
83
-
84
- _comp_compgen -- -W " $help "
81
+ _comp_compgen_help
82
+ _comp_compgen -a -- -W ' --skip-comments --skip-ssl'
85
83
[[ ${COMPREPLY-} == * = ]] && compopt -o nospace
86
84
return
87
85
;;
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ _comp_cmd_openssl()
41
41
local cur prev words cword comp_args
42
42
_comp_initialize -- " $@ " || return
43
43
44
- local commands command options formats
44
+ local commands command formats
45
45
46
46
commands=' asn1parse ca ciphers crl crl2pkcs7 dgst dh dhparam dsa dsaparam
47
47
ec ecparam enc engine errstr gendh gendsa genrsa nseq ocsp passwd
@@ -117,11 +117,13 @@ _comp_cmd_openssl()
117
117
118
118
if [[ $cur == -* ]]; then
119
119
# possible options for the command
120
- options= $( _parse_help " $1 " " $command -help" 2> /dev/null )
120
+ _comp_compgen_help -- " $command " -help
121
121
case $command in
122
- dgst | req | x509) options+=" $( _openssl_digests " $1 " ) " ;;
122
+ dgst | req | x509)
123
+ local options=$( _openssl_digests " $1 " )
124
+ _comp_compgen -a -- -W ' $options'
125
+ ;;
123
126
esac
124
- _comp_compgen -- -W " $options "
125
127
else
126
128
if [[ $command == speed ]]; then
127
129
COMPREPLY=($( compgen -W ' md2 mdc2 md5 hmac sha1 rmd160
Original file line number Diff line number Diff line change @@ -12,9 +12,8 @@ _comp_cmd_pwdx()
12
12
esac
13
13
14
14
if [[ $cur == -* ]]; then
15
- local help=$( _parse_help " $1 " )
16
- [[ $help ]] || help=-V
17
- _comp_compgen -- -W ' $help'
15
+ _comp_compgen_help ||
16
+ _comp_compgen -- -W ' -V'
18
17
else
19
18
_pids
20
19
fi
Original file line number Diff line number Diff line change @@ -46,7 +46,8 @@ _comp_cmd_rdesktop()
46
46
esac
47
47
48
48
if [[ $cur == -* ]]; then
49
- local opts=($( _parse_help " $1 " ) )
49
+ local -a opts
50
+ _comp_compgen -Rv opts help
50
51
(( ${# opts[@]} )) &&
51
52
_comp_compgen -- -W ' "${opts[@]%:}"'
52
53
else
You can’t perform that action at this time.
0 commit comments