Abort completion file loading earlier if required commands are not available.

Cuts ~10% from bash completion load time on two different systems I
just tested.
This commit is contained in:
Ville Skyttä 2011-04-05 00:35:51 +03:00
parent a7c3da6322
commit 9af6f3504e
161 changed files with 315 additions and 215 deletions

View File

@ -7,6 +7,7 @@ bash-completion (2.x)
* Drop rpm query support for rpm < 4.1.
* Split rpm and rpmbuild completions and improve them both.
* Add $_backup_glob for matching various backup files.
* Load speedups.
[ Guillaume Rousse ]
* added puppet completion, using work from Mathieu Parent (sathieudebian.org)

View File

@ -3,7 +3,8 @@
# bash completion for mock
have mock &&
have mock || return
_mock()
{
local cur prev plugins cfgdir split=false

View File

@ -19,7 +19,7 @@
# Test for existence of /etc/profile.d/modules.sh too because we may end up
# being sourced before it and thus before the `module' alias has been defined.
[ -f /etc/profile.d/modules.sh ] || have module && {
[ -f /etc/profile.d/modules.sh ] || have module || return
_module_list ()
{
@ -81,7 +81,6 @@ _module ()
return 0
} &&
complete -F _module -o default module
}
# Local variables:
# mode: shell-script

View File

@ -3,8 +3,8 @@
# svn completion
have svn &&
{
have svn || return
_svn()
{
local cur prev commands options command
@ -349,7 +349,6 @@ _svnlook()
return 0
} &&
complete -F _svnlook -o default svnlook
}
# Local variables:
# mode: shell-script

View File

@ -3,7 +3,8 @@
# yum(8) completion
have yum && {
have yum || return
_yum_list()
{
if [[ "$1" == all ]] ; then
@ -144,7 +145,6 @@ _yum()
--skip-broken --color' -- $cur ) )
return 0
fi
}
} &&
complete -F _yum yum

View File

@ -3,7 +3,8 @@
# bash completion for repomanage
have repomanage &&
have repomanage || return
_repomanage()
{
local cur prev

View File

@ -1,6 +1,7 @@
# abook(1) completion
have abook &&
have abook || return
_abook()
{
local cur prev

View File

@ -1,7 +1,7 @@
# bash completion for ant
have ant &&
{
have ant || return
_ant()
{
local cur prev buildfile i
@ -59,7 +59,6 @@ _ant()
} &&
have complete-ant-cmd.pl && \
complete -C complete-ant-cmd.pl -F _ant ant || complete -F _ant ant
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# apache2ctl(1) completion
have apache2ctl && {
have apache2ctl || return
_apache2ctl()
{
local APWORDS cur
@ -14,7 +15,6 @@ _apache2ctl()
COMPREPLY=( $( compgen -W "$APWORDS" -- "$cur" ) )
} &&
complete -F _apache2ctl apache2ctl
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# Debian apt-build(1) completion.
have apt-build &&
have apt-build || return
_apt_build()
{
local cur prev special i

View File

@ -1,6 +1,7 @@
# Debian aptitude(1) completion
have aptitude && {
have aptitude || return
have grep-status && {
_comp_dpkg_hold_packages()
{
@ -87,7 +88,6 @@ _aptitude()
return 0
} &&
complete -F _aptitude -o default aptitude
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# bash completion for aspell
have aspell && {
have aspell || return
_aspell_dictionary()
{
local datadir
@ -90,7 +91,6 @@ _aspell()
fi
} &&
complete -F _aspell aspell
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# autorpm(8) completion
have autorpm &&
have autorpm || return
_autorpm()
{
local cur

View File

@ -1,6 +1,7 @@
# bash completion for nslookup
have nslookup &&
have nslookup || return
_nslookup()
{
local cur

View File

@ -1,6 +1,7 @@
# BitKeeper completion adapted from code by Bart Trojanowski <bart@jukie.net>
have bk &&
have bk || return
_bk()
{
local BKCMDS

View File

@ -1,7 +1,8 @@
# btdownloadheadless(1) completion
have btdownloadheadless.py || have btdownloadcurses.py || \
have btdownloadgui.py &&
have btdownloadgui.py || return
_btdownload()
{
local cur prev

View File

@ -1,6 +1,7 @@
# bash completion for bluez utils
have hcitool && {
have hcitool || return
_bluetooth_adresses()
{
if [ -n "${COMP_BLUETOOTH_SCAN:-}" ]; then
@ -419,7 +420,6 @@ _avctrl()
fi
} &&
complete -F _avctrl avctrl
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# bash completion for brctl
have brctl &&
have brctl || return
_brctl()
{
local cur command

View File

@ -1,6 +1,7 @@
# bash completion for bzip2
have bzip2 || have pbzip2 &&
have bzip2 || have pbzip2 || return
_bzip2()
{
local cur prev xspec helpopts

View File

@ -1,6 +1,7 @@
# Linux cardctl(8) completion
have cardctl || have pccardctl &&
have cardctl || have pccardctl || return
_cardctl()
{
local cur

View File

@ -1,6 +1,7 @@
# bash completion for cfengine
have cfagent && {
have cfagent || return
_cfagent_options()
{
COMPREPLY=( $( compgen -W '--sysadm --force-net-copy --no-check-files \
@ -77,7 +78,6 @@ _cfrun()
esac
} &&
complete -F _cfrun cfrun
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# chkconfig(8) completion
have chkconfig &&
have chkconfig || return
_chkconfig()
{
local cur prev split=false

View File

@ -1,5 +1,7 @@
# chsh(1) completion
have chsh || return
_chsh()
{
local cur prev

View File

@ -1,6 +1,7 @@
# cksfv completion by Chris <xris@forevermore.net>
have cksfv &&
have cksfv || return
_cksfv()
{
local cur prev

View File

@ -1,7 +1,8 @@
# bash brogrammable completion for various Common Lisp implementations by
# Nikodemus Siivola <nikodemus@random-state.net>
have clisp &&
have clisp || return
_clisp()
{
local cur

View File

@ -1,5 +1,7 @@
# bash completion for configure
# No "have configure" here on purpose, it's rarely in any $PATH
_configure()
{
local cur prev split=false

View File

@ -1,6 +1,7 @@
# bash completion for cowsay
have cowsay &&
have cowsay || return
_cowsay()
{
local cur prev

View File

@ -1,6 +1,7 @@
# bash completion for cpan2dist
have cpan2dist &&
have cpan2dist || return
_cpan2dist()
{
local cur prev packagelist cpandirs

View File

@ -1,6 +1,7 @@
# bash completion for cpio
have cpio && {
have cpio || return
_cpio_format()
{
COMPREPLY=( $( compgen -W 'bin odc newc crc tar ustar hpbin hpodc' -- "$cur" ) )
@ -92,7 +93,6 @@ _cpio()
fi
} &&
complete -F _cpio cpio
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# crontab(1) completion
have crontab &&
have crontab || return
_crontab()
{
local cur prev

View File

@ -1,5 +1,7 @@
# bash completion for cryptsetup
have cryptsetup || return
_cryptsetup_name()
{
COMPREPLY=( $( compgen -X control -W '$( command ls /dev/mapper )' \
@ -12,7 +14,6 @@ _cryptsetup_device()
_filedir
}
have cryptsetup &&
_cryptsetup()
{
local cur prev arg

View File

@ -1,6 +1,7 @@
# bash completion for cups
have cancel &&
have cancel || return
_cancel()
{
local cur

View File

@ -1,6 +1,7 @@
# cvs(1) completion
have cvs && {
have cvs || return
set_prefix()
{
[ -z ${prefix:-} ] || prefix=${cur%/*}/
@ -381,7 +382,6 @@ _cvs()
return 0
} &&
complete -F _cvs -o default cvs
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# bash completion for cvsps
have cvsps &&
have cvsps || return
_cvsps()
{
COMPREPLY=()

View File

@ -1,6 +1,7 @@
# bash completion for dd
have dd &&
have dd || return
_dd()
{
local cur

View File

@ -1,6 +1,7 @@
# bash completion for dhclient
have dhclient &&
have dhclient || return
_dhclient()
{
local cur prev

View File

@ -1,6 +1,7 @@
# dict(1) completion
have dict || have rdict && {
have dict || have rdict || return
_dictdata()
{
dict $host $port $1 2>/dev/null | sed -ne \
@ -66,7 +67,6 @@ _dict()
COMPREPLY=( $( compgen -W '$( cat $dictfile )' -- "$cur" ) )
} &&
complete -F _dict -o default dict rdict
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# Debian Linux dselect(8) completion.
have dselect &&
have dselect || return
_dselect()
{
local cur prev

View File

@ -1,6 +1,7 @@
# dvd+rw-tools completions
have growisofs &&
have growisofs || return
_growisofs()
{
COMPREPLY=()

View File

@ -2,7 +2,8 @@
# globs and contains Linux specific code for completing the parameter
# to the -fstype option.
have find &&
have find || return
_find()
{
local cur prev i onlyonce

View File

@ -1,6 +1,7 @@
# bash completion for xfreerdp
have xfreerdp &&
have xfreerdp || return
_xfreerdp()
{
local cur prev

View File

@ -1,6 +1,7 @@
# bash completion for fuse
have fusermount &&
have fusermount || return
_fusermount()
{
COMPREPLY=()

View File

@ -8,7 +8,8 @@
# ask the driver ("g++") for the name of the compiler ("cc1"), and parse the
# --help output of the compiler.
have gcc &&
have gcc || return
_gcc()
{
local cur cc backend

View File

@ -1,7 +1,8 @@
# bash programmable completion for various Common Lisp implementations by
# Nikodemus Siivola <nikodemus@random-state.net>
have gcl &&
have gcl || return
_gcl()
{
local cur

View File

@ -1,6 +1,7 @@
# bash completion for gdb
have gdb &&
have gdb || return
_gdb()
{
local cur prev

View File

@ -1,6 +1,7 @@
# bash completion for mkisofs/genisoimage
have mkisofs || have genisoimage &&
have mkisofs || have genisoimage || return
_mkisofs()
{
local cur prev

View File

@ -1,6 +1,7 @@
# bash completion for getent
have getent &&
have getent || return
_getent()
{
local cur prev

View File

@ -1,6 +1,7 @@
# gkrellm(1) completion
have gkrellm || have gkrellm2 &&
have gkrellm || have gkrellm2 || return
_gkrellm()
{
local cur prev

View File

@ -1,6 +1,7 @@
# Gnatmake completion by Ralf_Schroth@t-online.de (Ralf Schroth)
have gnatmake &&
have gnatmake || return
_gnatmake()
{
local cur

View File

@ -1,6 +1,7 @@
# bash completion for gpg
have gpg &&
have gpg || return
_gpg()
{
local cur prev

View File

@ -1,6 +1,7 @@
# gpg2(1) completion
have gpg2 && {
have gpg2 || return
_gpg2()
{
local cur prev
@ -41,7 +42,6 @@ _gpg2()
fi
} &&
complete -F _gpg2 -o default gpg2
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# bash completion for gzip
have gzip || have pigz &&
have gzip || have pigz || return
_gzip()
{
local cur prev xspec helpopts

View File

@ -1,6 +1,7 @@
# bash completion for heimdal
have ktutil && {
have ktutil || return
_heimdal_principals()
{
COMPREPLY=( $( compgen -W "$( kadmin -l dump 2>/dev/null | \
@ -119,7 +120,6 @@ _ktutil()
fi
} &&
complete -F _ktutil ktutil
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# bash completion for hping2
have hping || have hping2 || have hping3 &&
have hping || have hping2 || have hping3 || return
_hping2()
{
local cur prev

View File

@ -1,6 +1,7 @@
# iconv(1) completion
have iconv &&
have iconv || return
_iconv()
{
local cur prev split=false

View File

@ -1,6 +1,7 @@
# iftop(8) completion
have iftop &&
have iftop || return
_iftop()
{
COMPREPLY=()

View File

@ -1,6 +1,7 @@
# Red Hat & Debian GNU/Linux if{up,down} completion
#
[ $USERLAND = GNU ] && { have ifup || have ifdown; } &&
[ $USERLAND = GNU ] && have ifup || have ifdown || return
_ifupdown()
{
local cur

View File

@ -1,6 +1,7 @@
# bash completion for ImageMagick
have convert && {
have convert || return
_ImageMagick()
{
local cur prev
@ -521,7 +522,6 @@ _stream()
fi
} &&
complete -F _stream stream
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# bash completion for info
have info &&
have info || return
_info()
{
local cur i infopath

View File

@ -1,6 +1,6 @@
# bash completion for ipmitool
have ipmitool && {
have ipmitool || return
_ipmitool_singleline_help()
{
@ -200,8 +200,6 @@ _ipmitool()
;;
esac
}
} &&
complete -F _ipmitool ipmitool

View File

@ -1,6 +1,7 @@
# iproute2 tools completion
have ip &&
have ip || return
_ip()
{
COMPREPLY=()

View File

@ -1,6 +1,7 @@
# Linux ipsec(8) completion (for FreeS/WAN)
#
[ $UNAME = Linux ] && have ipsec &&
[ $UNAME = Linux ] && have ipsec || return
_ipsec()
{
local cur

View File

@ -1,6 +1,7 @@
# bash completion for iptables
have iptables &&
have iptables || return
_iptables()
{
local cur prev table chain

View File

@ -1,4 +1,5 @@
have ipv6calc &&
have ipv6calc || return
_ipv6calc()
{
local cur prev split=false

View File

@ -1,6 +1,7 @@
# isql completion by Victor Bogado da Silva Lins <victor@bogado.net>
have isql &&
have isql || return
_isql()
{
local cur

View File

@ -1,6 +1,7 @@
# jar(1) completion
have jar &&
have jar || return
_jar()
{
local cur

View File

@ -1,6 +1,7 @@
# bash completion for k3b
have k3b &&
have k3b || return
_k3b()
{
local cur prev

View File

@ -1,7 +1,6 @@
# bash completion for FreeBSD kernel module commands
[ $UNAME = FreeBSD ] &&
{
[ $UNAME = FreeBSD ] || return
_kldload()
{
@ -29,8 +28,6 @@ _kldunload()
} &&
complete -F _kldunload kldunload
}
# Local variables:
# mode: shell-script
# sh-basic-offset: 4

View File

@ -1,6 +1,7 @@
# larch(1) completion by Alex Shinn <foof@synthcode.com>
have larch &&
have larch || return
_larch()
{
local cur prev

View File

@ -1,6 +1,7 @@
# bash completion for ldapvi
have ldapvi &&
have ldapvi || return
_ldapvi()
{
local cur prev

View File

@ -1,6 +1,7 @@
# bash completion for lilo(8)
have lilo && {
have lilo || return
_lilo_labels()
{
COMPREPLY=( $( compgen -W "$( awk -F'=' '/label/ {print $2}' \
@ -49,7 +50,6 @@ _lilo()
fi
} &&
complete -F _lilo lilo
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# bash completion for links
have links &&
have links || return
_links()
{
local cur

View File

@ -3,7 +3,8 @@
#
# bash completion for lintian(1) and lintian-info(1)
have lintian && {
have lintian || return
_lintian_tags()
{
local match search tags
@ -188,4 +189,3 @@ _lintian_info()
return 0
} &&
complete -F _lintian_info lintian-info
}

View File

@ -1,7 +1,8 @@
# bash programmable completion for various Common Lisp implementations by
# Nikodemus Siivola <nikodemus@random-state.net>
have lisp &&
have lisp || return
_lisp()
{
local cur

View File

@ -1,6 +1,7 @@
# lrzip(1) completion
have lrzip &&
have lrzip || return
_lrzip()
{
COMPREPLY=()

View File

@ -1,6 +1,7 @@
# lsof(8) completion
have lsof &&
have lsof || return
_lsof()
{
COMPREPLY=()

View File

@ -1,6 +1,7 @@
# bash completion for lvm
have lvm && {
have lvm || return
_volumegroups()
{
COMPREPLY=( $(compgen -W "$( vgscan 2>/dev/null | \
@ -1083,7 +1084,6 @@ _lvm()
fi
} &&
complete -F _lvm lvm
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# lzma(1) completion by Per Øyvind Karlsen <peroyvind@mandriva.org>
have lzma &&
have lzma || return
_lzma()
{
local cur prev xspec

View File

@ -1,6 +1,7 @@
# lzop(1) completion
have lzop &&
have lzop || return
_lzop()
{
local cur prev xspec

View File

@ -1,6 +1,7 @@
# bash completion for GNU make
have make || have gmake || have gnumake || have pmake &&
have make || have gmake || have gnumake || have pmake || return
_make()
{
local file makef makef_dir="." makef_inc cur prev i split=false

View File

@ -1,6 +1,7 @@
# bash completion for mc
have mc &&
have mc || return
_mc()
{
local cur prev split=false

View File

@ -1,6 +1,7 @@
# mcrypt(1) completion by Ariel Fermani <the_end@bbs.frc.utn.edu.ar>
have mcrypt || have mdecrypt &&
have mcrypt || have mdecrypt || return
_mcrypt()
{
local cur prev i decrypt

View File

@ -1,7 +1,7 @@
# bash completion for mdadm
have mdadm &&
{
have mdadm || return
_mdadm_raid_level()
{
local mode
@ -151,7 +151,6 @@ _mdadm()
fi
} &&
complete -F _mdadm mdadm
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# bash completion for medusa
have medusa &&
have medusa || return
_medusa()
{
local cur prev

View File

@ -1,6 +1,7 @@
# bash completion for minicom
have minicom &&
have minicom || return
_minicom()
{
local cur prev confdir

View File

@ -1,6 +1,7 @@
# bash completion for mkinitrd
have mkinitrd &&
have mkinitrd || return
_mkinitrd()
{
local cur prev args split=false

View File

@ -4,8 +4,7 @@
# query the server for a list of all available exports and complete on
# that instead.
#
have mount &&
{
have mount || return
# Just like COMPREPLY=(`compgen -W "${COMPREPLY[*]}" -- "$cur"`), only better!
#
@ -154,8 +153,6 @@ _umount()
} &&
complete -F _umount -o dirnames umount
}
# Local variables:
# mode: shell-script
# sh-basic-offset: 4

View File

@ -1,6 +1,7 @@
# mplayer(1) completion
have mplayer && {
have mplayer || return
_mplayer_options_list()
{
cur=${cur%\\}
@ -258,7 +259,6 @@ _mplayer()
return 0
} &&
complete -F _mplayer mplayer mencoder gmplayer kplayer
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# bash completion for msynctool
have msynctool &&
have msynctool || return
_msynctool()
{
local cur prev anteprev

View File

@ -1,6 +1,7 @@
# mtx completion by Jon Middleton <jjm@ixtab.org.uk>
have mtx &&
have mtx || return
_mtx()
{
local cur prev options tapes drives

View File

@ -3,7 +3,7 @@
# Mutt doesn't have an "addressbook" like Pine, but it has aliases and
# a "query" function to retrieve addresses, so that's what we use here.
have mutt || have muttng && {
have mutt || have muttng || return
# @param $1 (cur) Current word to complete
_muttaddr()
@ -175,7 +175,6 @@ _mutt()
esac
} &&
complete -F _mutt -o default mutt muttng
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# bash completion for mysqladmin
have mysqladmin &&
have mysqladmin || return
_mysqladmin()
{
local cur prev split=false

View File

@ -1,6 +1,7 @@
# bash completion for ncftp
have ncftp &&
have ncftp || return
_ncftp()
{
local cur

View File

@ -1,6 +1,7 @@
# bash completion for nmap
have nmap &&
have nmap || return
_nmap()
{
local cur prev

View File

@ -1,6 +1,7 @@
# bash completion for ntpdate
have ntpdate &&
have ntpdate || return
_ntpdate()
{
local cur prev

View File

@ -1,6 +1,7 @@
# iscsiadm(1) completion
have iscsiadm &&
have iscsiadm || return
_iscsiadm()
{
local cur prev mode split=false

View File

@ -1,6 +1,7 @@
# bash completion for openldap
have ldapsearch && {
have ldapsearch || return
_ldap_uris()
{
COMPREPLY=( $( compgen -W 'ldap:// ldaps://' -- "$cur" ) )
@ -255,7 +256,6 @@ _ldappasswd()
fi
} &&
complete -F _ldappasswd ldappasswd
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# bash completion for openssl
have openssl && {
have openssl || return
_openssl_sections()
{
local config f
@ -243,7 +244,6 @@ _openssl()
fi
} &&
complete -F _openssl -o default openssl
}
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,7 @@
# Perforce completion by Frank Cusack <frank@google.com>
have p4 &&
have p4 || return
_p4()
{
local cur prev words cword p4commands p4filetypes

View File

@ -1,7 +1,7 @@
# bash completion for perl
have perl &&
{
have perl || return
_perlmodules()
{
COMPREPLY=( $( compgen -P "$prefix" -W \
@ -127,7 +127,6 @@ _perldoc()
fi
} &&
complete -F _perldoc -o bashdefault perldoc
}
# Local variables:
# mode: shell-script

Some files were not shown because too many files have changed in this diff Show More