diff options
author | Michał Górny <mgorny@gentoo.org> | 2014-08-31 20:53:13 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2014-08-31 20:54:12 +0200 |
commit | 1d1cb2687fc7d60411eb9c91404f1714349a202e (patch) | |
tree | b83e575936022d52af1dcb5fb1e52ec19b891e31 /compat/gentoo-style-init | |
parent | Makefile: remove the outdated install target temporarily. (diff) | |
download | gentoo-bashcomp-1d1cb2687fc7d60411eb9c91404f1714349a202e.tar.gz gentoo-bashcomp-1d1cb2687fc7d60411eb9c91404f1714349a202e.tar.bz2 gentoo-bashcomp-1d1cb2687fc7d60411eb9c91404f1714349a202e.zip |
Move completions into subdirectories.
completions/ for files going to completionsdir, compat/ for those going
into compatdir.
Diffstat (limited to 'compat/gentoo-style-init')
-rw-r--r-- | compat/gentoo-style-init | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/compat/gentoo-style-init b/compat/gentoo-style-init new file mode 100644 index 0000000..e800c8c --- /dev/null +++ b/compat/gentoo-style-init @@ -0,0 +1,27 @@ +# Gentoo init.d completion +# +# $Id$ +# +# Copyright 1999-2009 Gentoo Foundation +# Distributed under the terms of the GNU General Public License, v2 or later + +_gentoo_style_init() +{ + local script="${COMP_WORDS[0]}" + local cur="${COMP_WORDS[$COMP_CWORD]}" + + if [[ ( -f "${script}" || -h "${script}" ) && -r "${script}" ]] \ + && [[ "${script}" != *.sh ]] \ + && [[ "$(head -n 1 "${script}")" = "#!/sbin/runscript" ]] + then + [[ $COMP_CWORD -gt 1 ]] && return 1 + COMPREPLY=($(opts="start stop status restart pause zap ineed needsme iuse usesme broken"; \ + eval "$(grep '^opts=' "${script}")"; echo "${opts}")) + [[ -n "$COMPREPLY" ]] || COMPREPLY=(start stop restart zap) + COMPREPLY=($(compgen -W "${COMPREPLY[*]}" -- "${cur}")) + else + COMPREPLY=($(compgen -o default -- "${cur}")) + fi + return 0 +} +complete -F _gentoo_style_init @GENTOO_PORTAGE_EPREFIX@/etc/init.d/* |