File tree 6 files changed +18
-17
lines changed
6 files changed +18
-17
lines changed Original file line number Diff line number Diff line change 5
5
6
6
_comp_cmd_adb__command_usage ()
7
7
{
8
- COMPREPLY=($( compgen -W \
9
- ' $("$1" help 2>&1 | command grep " ^ *\(adb \)\? *$2 " \
10
- | command sed -e "s/[]|[]/\n/g" | _parse_help -)' -- " $cur " ) )
8
+ COMPREPLY=($( compgen -W ' $("$1" help 2>&1 | \
9
+ command sed -e "/ ^ *\(adb \)\{0,1\} *$2 /!d;s/[]|[]/\n/g" | \
10
+ _parse_help -)' -- " $cur " ) )
11
11
}
12
12
13
13
_comp_cmd_adb ()
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ _comp_cmd_udevadm()
8
8
local cur prev words cword was_split comp_args
9
9
_comp_initialize -s -- " $@ " || return
10
10
11
- local i udevcmd has_udevcmd=" "
11
+ local i udevcmd= " " has_udevcmd=" "
12
12
for (( i = 1 ; i < cword; i++ )) ; do
13
13
if [[ ${words[i]} != -* ]]; then
14
14
udevcmd=${words[i]}
@@ -69,7 +69,7 @@ _comp_cmd_udevadm()
69
69
70
70
if [[ $cur == -* ]]; then
71
71
COMPREPLY=($( compgen -W \
72
- ' $("$1" ${udevcmd-} --help 2>/dev/null | _parse_help - )' -- " $cur " ) )
72
+ ' $(_parse_help "$1" " ${udevcmd-} --help" )' -- " $cur " ) )
73
73
[[ ${COMPREPLY-} == * = ]] && compopt -o nospace
74
74
fi
75
75
} &&
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ _comp_cmd_badblocks()
17
17
18
18
if [[ $cur == -* ]]; then
19
19
# Filter out -w (dangerous) and -X (internal use)
20
- COMPREPLY=($( compgen -X -[wX] -W ' $(_parse_usage "$1")' -- " $cur " ) )
20
+ COMPREPLY=($( compgen -X ' -[wX]' -W ' $(_parse_usage "$1")' -- " $cur " ) )
21
21
return
22
22
fi
23
23
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ _comp_cmd_complete()
40
40
local -a opts=($( compgen -W ' $(_parse_usage help "-s $1")' -- " $cur " ) )
41
41
# -F, -C do not work the expected way with compgen
42
42
[[ $1 != * compgen ]] || opts=(" ${opts[@]// -[FC]/ } " )
43
- COMPREPLY=($( compgen -W ' "${opts[@]}"' -- " $cur " ) )
43
+ COMPREPLY=($( compgen -W ' "${opts[@]}"' -X ' ' - - " $cur " ) )
44
44
else
45
45
COMPREPLY=($( compgen -A command -- " $cur " ) )
46
46
fi
Original file line number Diff line number Diff line change @@ -221,14 +221,18 @@ _comp_cmd_gnokii()
221
221
esac
222
222
fi
223
223
224
- # safer to use LANG=C
225
- local all_cmd=" $( LANG=C _parse_help " $1 " " --help all" ) "
226
- # these 2 below are allowed in combination with others
227
- local main_cmd=$( command grep -v -- ' --config\|--phone' <<< " $all_cmd" )
224
+ local all_cmd=" $( _parse_help " $1 " " --help all" ) "
228
225
226
+ # these 2 below are allowed in combination with others
227
+ local main_cmd
228
+ _comp_split -l main_cmd " $( command sed -e ' /--config/d;/--phone/d' -e \
229
+ ' s/[][\(){}|^$*+?.]/\\&/g' <<< " $all_cmd" ) "
229
230
# don't provide main command completions if one is
230
231
# already on the command line
231
- [[ $COMP_LINE =~ $( tr ' ' ' \b|' <<< " $main_cmd" ) ]] && return
232
+ local IFS=' |'
233
+ local regex_main_cmd=" (${main_cmd[*]} )($|[^_[:alnum:]])"
234
+ IFS=$' \t\n '
235
+ [[ $COMP_LINE =~ $regex_main_cmd ]] && return
232
236
233
237
COMPREPLY=($( compgen -W " $all_cmd " -- " $cur " ) )
234
238
} &&
Original file line number Diff line number Diff line change @@ -17,11 +17,8 @@ _comp_cmd_postfix()
17
17
esac
18
18
19
19
if [[ $cur == -* ]]; then
20
- COMPREPLY=($(
21
- compgen -W \
22
- ' $(_bashcomp_try_faketty "$1" --help 2>&1 | _parse_usage -)' \
23
- -- " $cur "
24
- ) )
20
+ COMPREPLY=($( compgen -W \
21
+ ' $(_parse_usage _bashcomp_try_faketty "$1 --help")' -- " $cur " ) )
25
22
return
26
23
fi
27
24
You can’t perform that action at this time.
0 commit comments