Explorar o código

fix problem with bash completion in old bash

Signed-off-by: Harald Albers <[email protected]>
Harald Albers %!s(int64=10) %!d(string=hai) anos
pai
achega
fa44a5fac2
Modificáronse 1 ficheiros con 8 adicións e 2 borrados
  1. 8 2
      contrib/completion/bash/docker-compose

+ 8 - 2
contrib/completion/bash/docker-compose

@@ -17,6 +17,12 @@
 #    . ~/.docker-compose-completion.sh
 
 
+# suppress trailing whitespace
+__docker_compose_nospace() {
+	# compopt is not available in ancient bash versions
+	type compopt &>/dev/null && compopt -o nospace
+}
+
 # For compatibility reasons, Compose and therefore its completion supports several
 # stack compositon files as listed here, in descending priority.
 # Support for these filenames might be dropped in some future version.
@@ -255,7 +261,7 @@ _docker_compose_run() {
 	case "$prev" in
 		-e)
 			COMPREPLY=( $( compgen -e -- "$cur" ) )
-			compopt -o nospace
+			__docker_compose_nospace
 			return
 			;;
 		--entrypoint|--name|--user|-u)
@@ -291,7 +297,7 @@ _docker_compose_scale() {
 			;;
 		*)
 			COMPREPLY=( $(compgen -S "=" -W "$(___docker_compose_all_services_in_compose_file)" -- "$cur") )
-			compopt -o nospace
+			__docker_compose_nospace
 			;;
 	esac
 }