Use _init_completion() in completions/c*.
This commit is contained in:
parent
007f7f5b01
commit
4c9789605f
2
CHANGES
2
CHANGES
@ -15,7 +15,7 @@ bash-completion (2.x)
|
||||
* Support tildes when recursively sourcing muttrc files (Debian: #615134).
|
||||
* Fix local variable leaks from various completions.
|
||||
* Add _init_completion() for common completion initialization and generic
|
||||
redirection handling.
|
||||
redirection handling, use it in many completions.
|
||||
|
||||
[ Guillaume Rousse ]
|
||||
* added puppet completion, using work from Mathieu Parent (sathieudebian.org)
|
||||
|
@ -4,12 +4,10 @@ have cardctl || have pccardctl || return
|
||||
|
||||
_cardctl()
|
||||
{
|
||||
local cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
|
||||
if [ $COMP_CWORD -eq 1 ]; then
|
||||
if [ $cword -eq 1 ]; then
|
||||
COMPREPLY=( $( compgen -W 'status config ident suspend \
|
||||
resume reset eject insert scheme' -- "$cur" ) )
|
||||
fi
|
||||
|
@ -15,10 +15,8 @@ _cfagent_options()
|
||||
|
||||
_cfagent()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-f|--file)
|
||||
@ -35,14 +33,12 @@ complete -F _cfagent cfagent
|
||||
|
||||
_cfrun()
|
||||
{
|
||||
local i section cfinputs cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
|
||||
section=1
|
||||
for (( i=1; i < COMP_CWORD; i++ )); do
|
||||
if [[ "${COMP_WORDS[i]}" == -- ]]; then
|
||||
local i section=1
|
||||
for (( i=1; i < cword; i++ )); do
|
||||
if [[ "${words[i]}" == -- ]]; then
|
||||
section=$((section + 1))
|
||||
fi
|
||||
done
|
||||
@ -60,9 +56,9 @@ _cfrun()
|
||||
COMPREPLY=( $( compgen -W '-f -h -d -S -T -v' -- $cur ) )
|
||||
else
|
||||
hostfile=${CFINPUTS:-/var/lib/cfengine/inputs}/cfrun.hosts
|
||||
for (( i=1; i < COMP_CWORD; i++ )); do
|
||||
if [[ "${COMP_WORDS[i]}" == -f ]]; then
|
||||
hostfile=${COMP_WORDS[i+1]}
|
||||
for (( i=1; i < cword; i++ )); do
|
||||
if [[ "${words[i]}" == -f ]]; then
|
||||
hostfile=${words[i+1]}
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
@ -4,11 +4,10 @@ have chkconfig || return
|
||||
|
||||
_chkconfig()
|
||||
{
|
||||
local cur prev split=false
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
local split=false
|
||||
_split_longopt && split=true
|
||||
|
||||
case $prev in
|
||||
@ -27,7 +26,7 @@ _chkconfig()
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '--list --add --del --override --level' -- "$cur" ) )
|
||||
else
|
||||
if [[ $COMP_CWORD -eq 2 || $COMP_CWORD -eq 4 ]]; then
|
||||
if [[ $cword -eq 2 || $cword -eq 4 ]]; then
|
||||
COMPREPLY=( $( compgen -W 'on off reset resetpriorities' -- "$cur" ) )
|
||||
else
|
||||
_services
|
||||
|
@ -4,10 +4,8 @@ have chsh || return
|
||||
|
||||
_chsh()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
--list-shells|--help|-v|--version)
|
||||
|
@ -4,12 +4,10 @@ have cksfv || return
|
||||
|
||||
_cksfv()
|
||||
{
|
||||
local cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
|
||||
if [ $COMP_CWORD -eq 1 ]; then
|
||||
if [ $cword -eq 1 ]; then
|
||||
COMPREPLY=( $( compgen -W '-C -f -i -q -v' -- "$cur" ) )
|
||||
return 0
|
||||
fi
|
||||
|
@ -5,10 +5,8 @@ have clisp || return
|
||||
|
||||
_clisp()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
# completing an option (may or may not be separated by a space)
|
||||
if [[ "$cur" == -* ]]; then
|
||||
|
7
completions/configure
vendored
7
completions/configure
vendored
@ -4,11 +4,10 @@
|
||||
|
||||
_configure()
|
||||
{
|
||||
local cur prev split=false
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
local split=false
|
||||
_split_longopt && split=true
|
||||
|
||||
case $prev in
|
||||
|
@ -5,11 +5,11 @@
|
||||
have chown &&
|
||||
_chown()
|
||||
{
|
||||
local cur prev split=false
|
||||
|
||||
# Get cur and prev words; but don't treat user:group as separate words.
|
||||
_get_comp_words_by_ref -n : cur prev
|
||||
local cur prev words cword
|
||||
# Don't treat user:group as separate words.
|
||||
_init_completion -n : || return
|
||||
|
||||
local split=false
|
||||
_split_longopt && split=true
|
||||
|
||||
case "$prev" in
|
||||
@ -28,7 +28,7 @@ _chown()
|
||||
if [[ "$cur" == -* ]]; then
|
||||
# Complete -options
|
||||
local w opts
|
||||
for w in "${COMP_WORDS[@]}" ; do
|
||||
for w in "${words[@]}" ; do
|
||||
[[ "$w" == -@(R|-recursive) ]] && opts="-H -L -P" && break
|
||||
done
|
||||
COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes --dereference \
|
||||
@ -55,12 +55,12 @@ complete -F _chown chown
|
||||
have chgrp &&
|
||||
_chgrp()
|
||||
{
|
||||
local cur prev split=false
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
cur=${cur//\\\\/}
|
||||
|
||||
local split=false
|
||||
_split_longopt && split=true
|
||||
|
||||
if [[ "$prev" == --reference ]]; then
|
||||
@ -73,7 +73,7 @@ _chgrp()
|
||||
# options completion
|
||||
if [[ "$cur" == -* ]]; then
|
||||
local w opts
|
||||
for w in "${COMP_WORDS[@]}" ; do
|
||||
for w in "${words[@]}" ; do
|
||||
[[ "$w" == -@(R|-recursive) ]] && opts="-H -L -P" && break
|
||||
done
|
||||
COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes --dereference \
|
||||
@ -83,7 +83,7 @@ _chgrp()
|
||||
fi
|
||||
|
||||
# first parameter on line or first since an option?
|
||||
if [[ $COMP_CWORD -eq 1 && "$cur" != -* || "$prev" == -* ]]; then
|
||||
if [[ $cword -eq 1 && "$cur" != -* || "$prev" == -* ]]; then
|
||||
_allowed_groups "$cur"
|
||||
else
|
||||
_filedir || return 0
|
||||
@ -98,10 +98,8 @@ complete -F _chgrp chgrp
|
||||
have id &&
|
||||
_id()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '-a -g --group -G --groups -n --name\
|
||||
@ -117,10 +115,10 @@ complete -F _id id
|
||||
have mktemp &&
|
||||
_mktemp()
|
||||
{
|
||||
COMPREPLY=()
|
||||
local cur prev split=false
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
local split=false
|
||||
_split_longopt && split=true
|
||||
|
||||
case "$prev" in
|
||||
|
@ -4,10 +4,8 @@ have cowsay || return
|
||||
|
||||
_cowsay()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-f)
|
||||
|
@ -4,10 +4,8 @@ have cpan2dist || return
|
||||
|
||||
_cpan2dist()
|
||||
{
|
||||
local cur prev packagelist cpandirs
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
--format)
|
||||
@ -32,7 +30,8 @@ _cpan2dist()
|
||||
--set-program --dist-opts --default-banlist \
|
||||
--default-ignorelist' -- $cur ) )
|
||||
else
|
||||
cpandirs=( "$HOME/.cpanplus/" "$HOME/.cpan/source/modules/" )
|
||||
local cpandirs=( "$HOME/.cpanplus/" "$HOME/.cpan/source/modules/" )
|
||||
local packagelist
|
||||
for dir in ${cpandirs[@]}; do
|
||||
[[ -d "$dir" && -r "$dir/02packages.details.txt.gz" ]] && \
|
||||
packagelist="$dir/02packages.details.txt.gz"
|
||||
|
@ -9,11 +9,10 @@ _cpio_format()
|
||||
|
||||
_cpio()
|
||||
{
|
||||
local cur prev split=false
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n : cur prev
|
||||
local cur prev words cword
|
||||
_init_completion -n : || return
|
||||
|
||||
local split=false
|
||||
_split_longopt && split=true
|
||||
|
||||
# --name value style option
|
||||
@ -39,11 +38,11 @@ _cpio()
|
||||
|
||||
$split && return 0
|
||||
|
||||
if [ $COMP_CWORD -eq 1 ]; then
|
||||
if [ $cword -eq 1 ]; then
|
||||
COMPREPLY=( $( compgen -W '-o --create -i --extract -p --pass-through \
|
||||
-? --help --license --usage --version' -- "$cur" ) )
|
||||
else
|
||||
case ${COMP_WORDS[1]} in
|
||||
case ${words[1]} in
|
||||
-o|--create)
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '-0 -a -c -v -A -B\
|
||||
|
@ -4,9 +4,8 @@ have crontab || return
|
||||
|
||||
_crontab()
|
||||
{
|
||||
local cur prev
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-u)
|
||||
@ -18,8 +17,8 @@ _crontab()
|
||||
local i opts=" -u -l -r -e" # leading space at start is significant...
|
||||
[[ $OSTYPE == *linux* ]] && opts+=" -i"
|
||||
[ -e /etc/selinux ] && opts+=" -s"
|
||||
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
|
||||
case "${COMP_WORDS[i]}" in
|
||||
for (( i=0; i < ${#words[@]}-1; i++ )); do
|
||||
case "${words[i]}" in
|
||||
-l)
|
||||
opts=${opts// -l -r -e/}
|
||||
opts=${opts// -i/}
|
||||
@ -37,7 +36,7 @@ _crontab()
|
||||
opts=${opts// -i/}
|
||||
;;
|
||||
-i|-s)
|
||||
opts=${opts// ${COMP_WORDS[i]}/}
|
||||
opts=${opts// ${words[i]}/}
|
||||
;;
|
||||
esac
|
||||
done
|
||||
@ -48,7 +47,7 @@ _crontab()
|
||||
fi
|
||||
|
||||
# do filenames only if we did not have -l, -r, or -e
|
||||
[[ "${COMP_LINE}" == *\ -@(l|r|e)* ]] || _filedir
|
||||
[[ "${words[@]}" == *\ -@(l|r|e)* ]] || _filedir
|
||||
} &&
|
||||
complete -F _crontab crontab
|
||||
|
||||
|
@ -16,10 +16,8 @@ _cryptsetup_device()
|
||||
|
||||
_cryptsetup()
|
||||
{
|
||||
local cur prev arg
|
||||
COMPREPLY=()
|
||||
cur=`_get_cword`
|
||||
prev=`_get_pword`
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
--key-file|--master-key-file|--header-backup-file|-d)
|
||||
@ -28,6 +26,7 @@ _cryptsetup()
|
||||
;;
|
||||
esac
|
||||
|
||||
local arg
|
||||
_get_first_arg
|
||||
if [ -z $arg ]; then
|
||||
if [[ "$cur" == -* ]]; then
|
||||
|
@ -4,10 +4,8 @@ have cancel || return
|
||||
|
||||
_cancel()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=( $( compgen -W "$( lpstat | cut -d' ' -f1 )" -- "$cur" ) )
|
||||
} &&
|
||||
|
@ -57,17 +57,17 @@ _cvs_roots()
|
||||
|
||||
_cvs()
|
||||
{
|
||||
local cur prev count mode i cvsroot cvsroots pwd
|
||||
local cur prev words cword
|
||||
_init_completion -n : || return
|
||||
|
||||
local count mode i cvsroot cvsroots pwd
|
||||
local -a flags miss files entries changed newremoved
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n : cur prev
|
||||
|
||||
count=0
|
||||
for i in "${COMP_WORDS[@]}"; do
|
||||
[ $count -eq $COMP_CWORD ] && break
|
||||
for i in "${words[@]}"; do
|
||||
[ $count -eq $cword ] && break
|
||||
# Last parameter was the CVSROOT, now go back to mode selection
|
||||
if [[ "${COMP_WORDS[((count))]}" == "$cvsroot" && "$mode" == cvsroot ]]; then
|
||||
if [[ "${words[((count))]}" == "$cvsroot" && "$mode" == cvsroot ]]; then
|
||||
mode=""
|
||||
fi
|
||||
if [ -z "$mode" ]; then
|
||||
@ -78,7 +78,7 @@ _cvs()
|
||||
;;
|
||||
-d)
|
||||
mode=cvsroot
|
||||
cvsroot=${COMP_WORDS[((count+1))]}
|
||||
cvsroot=${words[((count+1))]}
|
||||
;;
|
||||
ad|add|new)
|
||||
mode=add
|
||||
@ -155,7 +155,7 @@ _cvs()
|
||||
|
||||
if [[ "$cur" != -* ]]; then
|
||||
set_prefix
|
||||
if [[ $COMP_CWORD -gt 1 && -r ${prefix:-}CVS/Entries ]]; then
|
||||
if [[ $cword -gt 1 && -r ${prefix:-}CVS/Entries ]]; then
|
||||
get_entries
|
||||
[ -z "$cur" ] && \
|
||||
files=$( command ls -Ad !(CVS) ) || \
|
||||
@ -302,7 +302,7 @@ _cvs()
|
||||
remove)
|
||||
if [[ "$cur" != -* ]]; then
|
||||
set_prefix
|
||||
if [[ $COMP_CWORD -gt 1 && -r ${prefix:-}CVS/Entries ]]; then
|
||||
if [[ $cword -gt 1 && -r ${prefix:-}CVS/Entries ]]; then
|
||||
get_entries
|
||||
# find out what files are missing
|
||||
for i in "${entries[@]}"; do
|
||||
|
@ -4,9 +4,8 @@ have cvsps || return
|
||||
|
||||
_cvsps()
|
||||
{
|
||||
COMPREPLY=()
|
||||
local cur prev
|
||||
_get_comp_words_by_ref -n : cur prev
|
||||
local cur prev words cword
|
||||
_init_completion -n : || return
|
||||
|
||||
case $prev in
|
||||
-h|-z|-f|-d|-l|--diff-opts|--debuglvl)
|
||||
|
Loading…
x
Reference in New Issue
Block a user