summaryrefslogtreecommitdiff
path: root/completions/man
diff options
context:
space:
mode:
Diffstat (limited to 'completions/man')
-rw-r--r--completions/man51
1 files changed, 28 insertions, 23 deletions
diff --git a/completions/man b/completions/man
index e5a47361..81d06f51 100644
--- a/completions/man
+++ b/completions/man
@@ -10,29 +10,29 @@ _man()
local mansect="@([0-9lnp]|[0-9][px]|3?(gl|pm))"
case $prev in
- --config-file|-!(-*)C)
+ --config-file | -!(-*)C)
_filedir conf
return
;;
- --local-file|-!(-*)l)
+ --local-file | -!(-*)l)
_filedir "$manext"
return
;;
- --manpath|-!(-*)M)
+ --manpath | -!(-*)M)
_filedir -d
return
;;
- --pager|-!(-*)P)
+ --pager | -!(-*)P)
compopt -o filenames
- COMPREPLY=( $(compgen -c -- "$cur") )
+ COMPREPLY=($(compgen -c -- "$cur"))
return
;;
- --preprocessor|-!(-*)p)
- COMPREPLY=( $(compgen -W 'e p t g r v' -- "$cur") )
+ --preprocessor | -!(-*)p)
+ COMPREPLY=($(compgen -W 'e p t g r v' -- "$cur"))
return
;;
- --locale|--systems|--extension|--prompt|--recode|--encoding|\
- -!(-*)[LmerRE])
+ --locale | --systems | --extension | --prompt | --recode | --encoding | \
+ -!(-*)[LmerRE])
return
;;
esac
@@ -41,13 +41,13 @@ _man()
if [[ $cur == -* ]]; then
local opts=$(_parse_help "$1" -h)
- COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
# file based completion if parameter looks like a path
- if [[ "$cur" == @(*/|[.~])* ]]; then
+ if [[ $cur == @(*/|[.~])* ]]; then
_filedir "$manext"
return
fi
@@ -57,7 +57,8 @@ _man()
# determine manual section to search
local sect
- [[ "$prev" == $mansect ]] && sect=$prev || sect='*'
+ # shellcheck disable=SC2053
+ [[ $prev == $mansect ]] && sect=$prev || sect='*'
_expand || return
@@ -68,29 +69,33 @@ _man()
manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }"
fi
- local IFS=$' \t\n' reset=$(shopt -p failglob); shopt -u failglob
+ local IFS=$' \t\n' reset=$(shopt -p failglob)
+ shopt -u failglob
# redirect stderr for when path doesn't exist
- COMPREPLY=( $(eval command ls "$manpath" 2>/dev/null) )
+ COMPREPLY=($(eval command ls "$manpath" 2>/dev/null))
$reset
- # weed out directory path names and paths to man pages
- COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
- # strip suffix from man pages
- COMPREPLY=( ${COMPREPLY[@]%$comprsuffix} )
- COMPREPLY=( $(compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}") )
+ if ((${#COMPREPLY[@]} != 0)); then
+ # weed out directory path names and paths to man pages
+ COMPREPLY=(${COMPREPLY[@]##*/?(:)})
+ # strip suffix from man pages
+ COMPREPLY=(${COMPREPLY[@]%$comprsuffix})
+ COMPREPLY=($(compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}"))
+ fi
- if [[ "$prev" != $mansect ]]; then
+ # shellcheck disable=SC2053
+ if [[ $prev != $mansect ]]; then
# File based completion for the rest, prepending ./ if needed
# (man 1.6f needs that for man pages in current dir)
local i start=${#COMPREPLY[@]}
_filedir "$manext"
- for (( i=$start; i < ${#COMPREPLY[@]}; i++ )); do
+ for ((i = start; i < ${#COMPREPLY[@]}; i++)); do
[[ ${COMPREPLY[i]} == */* ]] || COMPREPLY[i]=./${COMPREPLY[i]}
done
fi
__ltrim_colon_completions "$cur"
} &&
-complete -F _man man apropos whatis
+ complete -F _man man apropos whatis
# ex: filetype=sh