Browse Source

Fix bash completion for `docker inspect --type`

Signed-off-by: Harald Albers <github@albersweb.de>
Harald Albers 8 years ago
parent
commit
d65934a8b8
1 changed files with 5 additions and 3 deletions
  1. 5 3
      contrib/completion/bash/docker

+ 5 - 3
contrib/completion/bash/docker

@@ -2184,9 +2184,11 @@ _docker_info() {
 }
 }
 
 
 _docker_inspect() {
 _docker_inspect() {
+	local preselected_type
 	local type
 	local type
 
 
 	if [ "$1" = "--type" ] ; then
 	if [ "$1" = "--type" ] ; then
+		preselected_type=yes
 		type="$2"
 		type="$2"
 	else
 	else
 		type=$(__docker_value_of_option --type)
 		type=$(__docker_value_of_option --type)
@@ -2197,17 +2199,17 @@ _docker_inspect() {
 			return
 			return
 			;;
 			;;
 		--type)
 		--type)
-			if [ -z "$type" ] ; then
+			if [ -z "$preselected_type" ] ; then
 				COMPREPLY=( $( compgen -W "image container" -- "$cur" ) )
 				COMPREPLY=( $( compgen -W "image container" -- "$cur" ) )
+				return
 			fi
 			fi
-			return
 			;;
 			;;
 	esac
 	esac
 
 
 	case "$cur" in
 	case "$cur" in
 		-*)
 		-*)
 			local options="--format -f --help --size -s"
 			local options="--format -f --help --size -s"
-			if [ -z "$type" ] ; then
+			if [ -z "$preselected_type" ] ; then
 				options+=" --type"
 				options+=" --type"
 			fi
 			fi
 			COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
 			COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )