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))))'
|
_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
|
# This function completes on services
|
||||||
#
|
#
|
||||||
_services()
|
_services()
|
||||||
{
|
{
|
||||||
local sysvdir famdir
|
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
|
famdir=/etc/xinetd.d
|
||||||
|
|
||||||
local restore_nullglob=$(shopt -p nullglob); shopt -s nullglob
|
local restore_nullglob=$(shopt -p nullglob); shopt -s nullglob
|
||||||
@ -1843,7 +1857,7 @@ _completion_loader()
|
|||||||
[[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions"
|
[[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions"
|
||||||
|
|
||||||
# Special case for init.d scripts.
|
# 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
|
. "$compdir/service" &>/dev/null && return 124 || return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -15,9 +15,7 @@ _service()
|
|||||||
if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then
|
if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then
|
||||||
_services
|
_services
|
||||||
else
|
else
|
||||||
local sysvdir
|
local sysvdir=$( _sysvdir )
|
||||||
[ -d /etc/rc.d/init.d ] && \
|
|
||||||
sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
|
|
||||||
COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \
|
COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \
|
||||||
-ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \
|
-ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \
|
||||||
$sysvdir/${prev##*/} 2>/dev/null` start stop' -- "$cur" ) )
|
$sysvdir/${prev##*/} 2>/dev/null` start stop' -- "$cur" ) )
|
||||||
@ -26,7 +24,7 @@ _service()
|
|||||||
return 0
|
return 0
|
||||||
} &&
|
} &&
|
||||||
complete -F _service service
|
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
|
[ -x "$svc" ] && complete -F _service $svc
|
||||||
done
|
done
|
||||||
unset svc
|
unset svc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user