diff --git a/completions/man b/completions/man index 84f43fd51d6..62554997903 100644 --- a/completions/man +++ b/completions/man @@ -99,12 +99,12 @@ _man() fi # shellcheck disable=SC2053 - if [[ $prev != $mansect ]]; then - # File based completion for the rest, prepending ./ if needed + if [[ $prev != $mansect && -z ${COMPREPLY-} ]]; then + # File based completion, prepending ./ if needed # (man 1.6f needs that for man pages in current dir) - local i start=${#COMPREPLY[@]} + local i _filedir "$manext" - for ((i = start; i < ${#COMPREPLY[@]}; i++)); do + for i in "${!COMPREPLY[@]}"; do [[ ${COMPREPLY[i]} == */* ]] || COMPREPLY[i]=./${COMPREPLY[i]} done fi