Commit bdeeb9db authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #31135 from xingzhou/bash_completion_bug

Automatic merge from submit-queue Fixed two issues of kubectl bash completion. This patch includes the fix of the following issue: • Correct the method invocation from "__kubectl_namespace_flag" to "__kubectl_override_flags" • Support bash completion if "--namespace=xxx" style flags are specified in the kubectl command Fixes #31134
parents 74b01041 48100f71
...@@ -47,7 +47,7 @@ __kubectl_override_flags() ...@@ -47,7 +47,7 @@ __kubectl_override_flags()
for of in "${__kubectl_override_flag_list[@]}"; do for of in "${__kubectl_override_flag_list[@]}"; do
case "${w}" in case "${w}" in
--${of}=*) --${of}=*)
eval "${of}=\"--${of}=\${w}\"" eval "${of}=\"${w}\""
;; ;;
--${of}) --${of})
two_word_of="${of}" two_word_of="${of}"
...@@ -115,7 +115,7 @@ __kubectl_get_containers() ...@@ -115,7 +115,7 @@ __kubectl_get_containers()
fi fi
local last=${nouns[${len} -1]} local last=${nouns[${len} -1]}
local kubectl_out local kubectl_out
if kubectl_out=$(kubectl get $(__kubectl_namespace_flag) -o template --template="${template}" pods "${last}" 2>/dev/null); then if kubectl_out=$(kubectl get $(__kubectl_override_flags) -o template --template="${template}" pods "${last}" 2>/dev/null); then
COMPREPLY=( $( compgen -W "${kubectl_out[*]}" -- "$cur" ) ) COMPREPLY=( $( compgen -W "${kubectl_out[*]}" -- "$cur" ) )
fi fi
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment