[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-514-g1a01e54
Ville Skyttä
ville.skytta at iki.fi
Sun Nov 6 12:22:54 UTC 2011
The following commit has been merged in the master branch:
commit 1a01e54d856fe2d9496cfaf6d9df8b75d87a9b52
Author: Ville Skyttä <ville.skytta at iki.fi>
Date: Sun Nov 6 14:22:39 2011 +0200
Another stab at making service completion work on Slackware.
diff --git a/bash_completion b/bash_completion
index 1ef7030..9c96db7 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1043,9 +1043,12 @@ _backup_glob='@(#*#|*@(~|.@(bak|orig|rej|swp|dpkg*|rpm@(orig|new|save))))'
#
_services()
{
- local sysvdir famdir
- [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
- famdir=/etc/xinetd.d
+ local sysvdir=/etc/init.d famdir=/etc/xinetd.d
+ if [[ -d /etc/rc.d/init.d ]]; then
+ sysvdir=/etc/rc.d/init.d
+ elif [[ -f /etc/slackware-version ]]; then
+ sysvdir=/etc/rc.d
+ fi
local restore_nullglob=$(shopt -p nullglob); shopt -s nullglob
@@ -1843,7 +1846,8 @@ _completion_loader()
[[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions"
# Special case for init.d scripts.
- if [[ $1 == /etc?(/rc.d)/init.d/* ]]; then
+ if [[ $1 == /etc?(/rc.d)/init.d/* || \
+ ( $1 == /etc/rc.d/* && -f /etc/slackware-version ) ]]; then
. "$compdir/service" &>/dev/null && return 124 || return 1
fi
diff --git a/completions/service b/completions/service
index f008770..e359ef4 100644
--- a/completions/service
+++ b/completions/service
@@ -15,9 +15,12 @@ _service()
if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then
_services
else
- local sysvdir
- [ -d /etc/rc.d/init.d ] && \
- sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
+ local sysvdir=/etc/init.d
+ if [[ -d /etc/rc.d/init.d ]]; then
+ sysvdir=/etc/rc.d/init.d
+ elif [[ -f /etc/slackware-version ]]; then
+ sysvdir=/etc/rc.d
+ fi
COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \
-ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \
$sysvdir/${prev##*/} 2>/dev/null` start stop' -- "$cur" ) )
@@ -26,9 +29,14 @@ _service()
return 0
} &&
complete -F _service service
-for svc in /etc/init.d/!($_backup_glob) /etc/rc.d/init.d/!($_backup_glob); do
- [ -x "$svc" ] && complete -F _service $svc
+
+svcdirs=( /etc/init.d /etc/rc.d/init.d )
+[[ -f /etc/slackware-version ]] && svcdirs=( /etc/rc.d )
+for svcdir in ${svcdirs[@]}; do
+ for svc in $svcdir/!($_backup_glob); do
+ [ -x "$svc" ] && complete -F _service $svc
+ done
done
-unset svc
+unset svc svcdir svcdirs
# ex: ts=4 sw=4 et filetype=sh
--
bash-completion
More information about the Bash-completion-commits
mailing list