From 1ea3da1eb64e5284aca86e6b04cfd8e296383815 Mon Sep 17 00:00:00 2001 From: ohmystack Date: Tue, 23 Aug 2016 01:42:05 +0800 Subject: [PATCH] Fix named pipe in kubectl zsh completion In zsh and bash, a multi-line named pipe, who is wrapped by parenthesis, is possible to mismatch the right parenthesis, even that parenthesis is in a here-document. So, we move the code into a function, and use an inline named pipe. Signed-off-by: ohmystack --- pkg/kubectl/cmd/completion.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/kubectl/cmd/completion.go b/pkg/kubectl/cmd/completion.go index eb61a332db0..f7017daf667 100644 --- a/pkg/kubectl/cmd/completion.go +++ b/pkg/kubectl/cmd/completion.go @@ -245,7 +245,8 @@ if sed --help 2>&1 | grep -q GNU; then RWORD='\>' fi -__kubectl_bash_source <(sed \ +__kubectl_convert_bash_to_zsh() { + sed \ -e 's/declare -F/whence -w/' \ -e 's/local \([a-zA-Z0-9_]*\)=/local \1; \1=/' \ -e 's/flags+=("\(--.*\)=")/flags+=("\1"); two_word_flags+=("\1")/' \ @@ -267,7 +268,9 @@ __kubectl_bash_source <(sed \ zsh_tail := ` BASH_COMPLETION_EOF -) +} + +__kubectl_bash_source <(__kubectl_convert_bash_to_zsh) ` out.Write([]byte(zsh_tail)) return nil