summaryrefslogtreecommitdiffstats
path: root/completions/info
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:03:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:03:19 +0000
commit6c09f2a45c5541e9c207d14fc7aa21a4a0066bde (patch)
tree0221189d367bf661f6f9493c4f17a03f0dd4b7d2 /completions/info
parentReleasing progress-linux version 1:2.11-8~progress7.99u1. (diff)
downloadbash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.tar.xz
bash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.zip
Merging upstream version 1:2.12.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'completions/info')
-rw-r--r--completions/info62
1 files changed, 29 insertions, 33 deletions
diff --git a/completions/info b/completions/info
index f50f842..3a13565 100644
--- a/completions/info
+++ b/completions/info
@@ -1,40 +1,42 @@
# bash completion for info -*- shell-script -*-
-_info()
+_comp_cmd_info()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
# default completion if parameter looks like a path
if [[ $cur == @(*/|[.~])* ]]; then
- _filedir
+ _comp_compgen_filedir
return
fi
+ local noargopts='!(-*|*[kndfor]*)'
+ # shellcheck disable=SC2254
case $prev in
- --apropos | --index-search | --node | --help | --version | -!(-*)[knhv])
+ --apropos | --index-search | --node | --help | --version | -${noargopts}[knhv])
return
;;
- -!(-*)d)
+ -${noargopts}d)
if [[ ${1##*/} == info ]]; then
- _filedir -d
+ _comp_compgen_filedir -d
return
fi
;;
--directory)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
- --dribble | --file | --output | --restore | --raw-filename | --rcfile | -!(-*)[for])
- _filedir
+ --dribble | --file | --output | --restore | --raw-filename | --rcfile | -${noargopts}[for])
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
@@ -47,28 +49,22 @@ _info()
infopath=$INFOPATH
fi
- _expand || return
-
- infopath=$infopath:
- if [[ -n $cur ]]; then
- infopath="${infopath//://$cur* }"
- else
- infopath="${infopath//:// }"
+ _comp_split -F : infopath "$infopath"
+ if ((${#infopath[@]})); then
+ _comp_compgen -Rv infopath -- -S "/$cur*" -W '"${infopath[@]}"'
+ local IFS=
+ if _comp_expand_glob COMPREPLY '${infopath[@]}'; then
+ # weed out directory path names and paths to info pages (empty
+ # elements will be removed by the later `compgen -X ''`)
+ COMPREPLY=("${COMPREPLY[@]##*/?(:)}")
+ # strip suffix from info pages
+ COMPREPLY=("${COMPREPLY[@]%.@(gz|bz2|xz|lzma)}")
+ # weed out info dir file with -X 'dir'
+ _comp_compgen -c "${cur//\\\\/}" -- -W '"${COMPREPLY[@]%.*}"' -X '@(|dir)'
+ fi
+ _comp_unlocal IFS
fi
-
- # redirect stderr for when path doesn't exist
- COMPREPLY=($(eval command ls "$infopath" 2>/dev/null))
- # weed out directory path names and paths to info pages
- COMPREPLY=(${COMPREPLY[@]##*/?(:)})
- # weed out info dir file
- for i in ${!COMPREPLY[*]}; do
- [[ ${COMPREPLY[i]} == dir ]] && unset "COMPREPLY[i]"
- done
- # strip suffix from info pages
- COMPREPLY=(${COMPREPLY[@]%.@(gz|bz2|xz|lzma)})
- COMPREPLY=($(compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}"))
-
} &&
- complete -F _info info pinfo
+ complete -F _comp_cmd_info info pinfo
# ex: filetype=sh