_services: Split xinetd service completion into _xinetd_services.

Only Mandriva's service operates on xinetd services, chkconfig does it
everywhere.
master
Ville Skyttä 2011-11-09 18:14:23 +02:00
parent e4ff8d98a3
commit 3f851722d7
2 changed files with 18 additions and 9 deletions

View File

@ -1050,28 +1050,34 @@ _gids()
# #
_backup_glob='@(#*#|*@(~|.@(bak|orig|rej|swp|dpkg*|rpm@(orig|new|save))))' _backup_glob='@(#*#|*@(~|.@(bak|orig|rej|swp|dpkg*|rpm@(orig|new|save))))'
# Complete on xinetd services
#
_xinetd_services()
{
local xinetddir=/etc/xinetd.d
if [[ -d $xinetddir ]]; then
local restore_nullglob=$(shopt -p nullglob); shopt -s nullglob
local -a svcs=( $( printf '%s\n' $xinetddir/!($_backup_glob) ) )
$restore_nullglob
COMPREPLY+=( $( compgen -W '${svcs[@]#$xinetddir/}' -- "$cur" ) )
fi
}
# This function completes on services # This function completes on services
# #
_services() _services()
{ {
local sysvdirs famdir=/etc/xinetd.d local sysvdirs
_sysvdirs _sysvdirs
local restore_nullglob=$(shopt -p nullglob); shopt -s nullglob local restore_nullglob=$(shopt -p nullglob); shopt -s nullglob
COMPREPLY=( $( printf '%s\n' ${sysvdirs[0]}/!($_backup_glob|functions) ) ) COMPREPLY=( $( printf '%s\n' ${sysvdirs[0]}/!($_backup_glob|functions) ) )
if [ -d $famdir ]; then
COMPREPLY+=( $( printf '%s\n' $famdir/!($_backup_glob) ) )
fi
$restore_nullglob $restore_nullglob
COMPREPLY+=( $( systemctl list-units --full --all 2>/dev/null | \ COMPREPLY+=( $( systemctl list-units --full --all 2>/dev/null | \
awk '$1 ~ /\.service$/ { sub("\\.service$", "", $1); print $1 }' ) ) awk '$1 ~ /\.service$/ { sub("\\.service$", "", $1); print $1 }' ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]#@(${sysvdirs[0]}|$famdir)/}' \ COMPREPLY=( $( compgen -W '${COMPREPLY[@]#${sysvdirs[0]}/}' -- "$cur" ) )
-- "$cur" ) )
} }
# This completes on a list of all available service scripts for the # This completes on a list of all available service scripts for the
@ -1088,6 +1094,7 @@ _service()
if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then
_services _services
[[ -e /etc/mandrake-release ]] && _xinetd_services
else else
local sysvdirs local sysvdirs
_sysvdirs _sysvdirs

View File

@ -8,6 +8,7 @@ _chkconfig()
case $prev in case $prev in
--level=[1-6]|[1-6]|--list|--add|--del|--override) --level=[1-6]|[1-6]|--list|--add|--del|--override)
_services _services
_xinetd_services
return 0 return 0
;; ;;
--level) --level)
@ -27,6 +28,7 @@ _chkconfig()
-- "$cur" ) ) -- "$cur" ) )
else else
_services _services
_xinetd_services
fi fi
fi fi
} && } &&