[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-525-ge4cdcca
Igor Murzov
e-mail at date.by
Wed Nov 9 13:12:21 UTC 2011
The following commit has been merged in the master branch:
commit e4cdcca08ee486e0354d1872ab997bb08e88b569
Author: Igor Murzov <e-mail at date.by>
Date: Wed Nov 9 05:21:53 2011 +0300
Merge completions/service into the bash_completion script.
If completion for a basename foo is already installed, the default
completion loader no longer fires for /etc/init.d/foo -- the basename
completion is invoked directly instead. This means that we need to load
completions for /etc/init.d and friends eagerly at bash_completion load :(
diff --git a/bash_completion b/bash_completion
index 7223425..497dbb5 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1074,6 +1074,37 @@ _services()
-- "$cur" ) )
}
+# This completes on a list of all available service scripts for the
+# 'service' command and/or the SysV init.d directory, followed by
+# that script's available commands
+#
+_service()
+{
+ local cur prev words cword
+ _init_completion || return
+
+ # don't complete past 2nd token
+ [ $cword -gt 2 ] && return 0
+
+ if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then
+ _services
+ else
+ local sysvdirs
+ _sysvdirs
+ COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \
+ -ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \
+ ${sysvdirs[0]}/${prev##*/} 2>/dev/null` start stop' -- "$cur" ) )
+ fi
+} &&
+complete -F _service service
+_sysvdirs
+for svcdir in ${sysvdirs[@]}; do
+ for svc in $svcdir/!($_backup_glob); do
+ [ -x "$svc" ] && complete -F _service $svc
+ done
+done
+unset svc svcdir sysvdirs
+
# This function completes on modules
#
_modules()
@@ -1848,11 +1879,6 @@ _completion_loader()
local compdir=./completions
[[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions"
- # Special case for init.d scripts.
- if [[ $1 == /etc/@(rc.d|init.d)/* ]]; then
- . "$compdir/service" &>/dev/null && return 124 || return 1
- fi
-
# Try basename.
. "$compdir/${1##*/}" &>/dev/null && return 124
diff --git a/completions/service b/completions/service
deleted file mode 100644
index 147aad4..0000000
--- a/completions/service
+++ /dev/null
@@ -1,36 +0,0 @@
-# service(8) and /etc/init.d/* completion -*- shell-script -*-
-
-# This completes on a list of all available service scripts for the
-# 'service' command and/or the SysV init.d directory, followed by
-# that script's available commands
-
-_service()
-{
- local cur prev words cword
- _init_completion || return
-
- # don't complete past 2nd token
- [ $cword -gt 2 ] && return 0
-
- if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then
- _services
- else
- local sysvdirs
- _sysvdirs
- COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \
- -ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \
- ${sysvdirs[0]}/${prev##*/} 2>/dev/null` start stop' -- "$cur" ) )
- fi
-
- return 0
-} &&
-complete -F _service service
-_sysvdirs
-for svcdir in ${sysvdirs[@]}; do
- for svc in $svcdir/!($_backup_glob); do
- [ -x "$svc" ] && complete -F _service $svc
- done
-done
-unset svc svcdir sysvdirs
-
-# ex: ts=4 sw=4 et filetype=sh
--
bash-completion
More information about the Bash-completion-commits
mailing list