4 local -a inits xinetds alls
7 if chkconfig --list > /dev/null 2>&1; then
8 alls=( ${(f)"$(LANGUAGE=C LANG=C LC_ALL=C chkconfig --list)"} )
9 inits=( ${${${alls[1,(r)xinetd based*]}[1,-2]}/%[[:space:]]*/} )
10 xinetds=( ${${${${alls[(r)xinetd based*,-1]}[2,-1]}/#[[:space:]]#}/%:*} )
13 'init:init service:compadd -a inits' \
14 'xinetd:xinetd service:compadd -a xinetds' && ret=0
16 services_directory=`[ -d /etc/init.d ] && echo /etc/init.d || echo /etc/rc.d`;
17 _wanted services expl service compadd "$@" - $services_directory/*(-*:t) && ret=0
24 local magic cmds what script
29 [[ $script = */* ]] || script=`[ -d /etc/init.d ] && echo /etc/init.d || echo /etc/rc.d`/$script
31 what='(st(art|op|atus)|(force-|)re(start|load)|debug_(up|down)|dump(|_stats)|add|delete|clean|list|config(|ure))'
33 read -u0 -k2 magic < $script && [[ $magic = '#!' ]] &&
34 cmds=( ${${(j:|:s:|:)${(M)${(f)"$(< $script)"}:#[[:blank:]]#(\'|)${~what}([[:blank:]]#\|[[:blank:]]#${~what})#(\'|)\)}}//[^-a-z_]} )
36 (( $#cmds )) || zstyle -a ":completion:${curcontext}:commands" commands cmds ||
44 2) # Show services under /etc/rc.d
47 3) # Show subcommands for current service
49 # This is here so that _init_d works on the service name rather
50 # than on the actual function name "svc"
54 # Append enable and disable as service subcommands
55 compadd enable disable
57 # Append available subcommands for current service