service, _services: Make these work on Slackware GNU/Linux.
This commit is contained in:
parent
bc2d3c9a34
commit
9717124ab7
@ -1039,12 +1039,26 @@ _gids()
|
||||
#
|
||||
_backup_glob='@(#*#|*@(~|.@(bak|orig|rej|swp|dpkg*|rpm@(orig|new|save))))'
|
||||
|
||||
# This function sets correct SysV init directory
|
||||
#
|
||||
_sysvdir()
|
||||
{
|
||||
if [ -f /etc/slackware-version ]; then
|
||||
# Slackware uses /etc/rc.d
|
||||
echo /etc/rc.d
|
||||
elif [ -d /etc/rc.d/init.d ]; then
|
||||
echo /etc/rc.d/init.d
|
||||
else
|
||||
echo /etc/init.d
|
||||
fi
|
||||
}
|
||||
|
||||
# This function completes on services
|
||||
#
|
||||
_services()
|
||||
{
|
||||
local sysvdir famdir
|
||||
[ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
|
||||
sysvdir=$( _sysvdir )
|
||||
famdir=/etc/xinetd.d
|
||||
|
||||
local restore_nullglob=$(shopt -p nullglob); shopt -s nullglob
|
||||
@ -1843,7 +1857,7 @@ _completion_loader()
|
||||
[[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions"
|
||||
|
||||
# Special case for init.d scripts.
|
||||
if [[ $1 == /etc?(/rc.d)/init.d/* ]]; then
|
||||
if [[ "$1" == $( _sysvdir )/* ]]; then
|
||||
. "$compdir/service" &>/dev/null && return 124 || return 1
|
||||
fi
|
||||
|
||||
|
@ -15,9 +15,7 @@ _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=$( _sysvdir )
|
||||
COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \
|
||||
-ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \
|
||||
$sysvdir/${prev##*/} 2>/dev/null` start stop' -- "$cur" ) )
|
||||
@ -26,7 +24,7 @@ _service()
|
||||
return 0
|
||||
} &&
|
||||
complete -F _service service
|
||||
for svc in /etc/init.d/!($_backup_glob) /etc/rc.d/init.d/!($_backup_glob); do
|
||||
for svc in $( _sysvdir )/!($_backup_glob); do
|
||||
[ -x "$svc" ] && complete -F _service $svc
|
||||
done
|
||||
unset svc
|
||||
|
Loading…
x
Reference in New Issue
Block a user