completions: Fix bash completions when a option requires a argument

Since the string of options variable as pattern in the case statement has
not been delimited and it does not match the value of prev variable,
bash completions tries to complement any option even when a specified
option requires a argument.
This fix stops complementing options when a option requires a argument.

Signed-off-by: ERAMOTO Masaya <eramoto.masaya@jp.fujitsu.com>
This commit is contained in:
ERAMOTO Masaya 2019-01-22 19:27:26 +09:00
parent 42b01df89e
commit 790620024e

View File

@ -6,11 +6,14 @@ _complete_() {
local options_with_args=$1
local boolean_options="$2 -h --help"
case "$prev" in
$options_with_args)
return
;;
esac
local option_with_args
for option_with_args in $options_with_args
do
if [ "$option_with_args" == "$prev" ]
then
return
fi
done
case "$cur" in
-*)