Skip to content

Commit c32b93a

Browse files
authored
Merge pull request kubernetes#89479 from knight42/fix/zsh-completion-file-flag
fix(kubectl): remove trailing space when completing file path
2 parents 3c7258d + 2fefd9e commit c32b93a

File tree

1 file changed

+3
-43
lines changed

1 file changed

+3
-43
lines changed

staging/src/k8s.io/kubectl/pkg/cmd/completion/completion.go

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -223,49 +223,9 @@ __kubectl_get_comp_words_by_ref() {
223223
}
224224
225225
__kubectl_filedir() {
226-
local RET OLD_IFS w qw
227-
228-
__kubectl_debug "_filedir $@ cur=$cur"
229-
if [[ "$1" = \~* ]]; then
230-
# somehow does not work. Maybe, zsh does not call this at all
231-
eval echo "$1"
232-
return 0
233-
fi
234-
235-
OLD_IFS="$IFS"
236-
IFS=$'\n'
237-
if [ "$1" = "-d" ]; then
238-
shift
239-
RET=( $(compgen -d) )
240-
else
241-
RET=( $(compgen -f) )
242-
fi
243-
IFS="$OLD_IFS"
244-
245-
IFS="," __kubectl_debug "RET=${RET[@]} len=${#RET[@]}"
246-
247-
for w in ${RET[@]}; do
248-
if [[ ! "${w}" = "${cur}"* ]]; then
249-
continue
250-
fi
251-
if eval "[[ \"\${w}\" = *.$1 || -d \"\${w}\" ]]"; then
252-
qw="$(__kubectl_quote "${w}")"
253-
if [ -d "${w}" ]; then
254-
COMPREPLY+=("${qw}/")
255-
else
256-
COMPREPLY+=("${qw}")
257-
fi
258-
fi
259-
done
260-
}
261-
262-
__kubectl_quote() {
263-
if [[ $1 == \'* || $1 == \"* ]]; then
264-
# Leave out first character
265-
printf %q "${1:1}"
266-
else
267-
printf %q "$1"
268-
fi
226+
# Don't need to do anything here.
227+
# Otherwise we will get trailing space without "compopt -o nospace"
228+
true
269229
}
270230
271231
autoload -U +X bashcompinit && bashcompinit

0 commit comments

Comments
 (0)