26763: fix problem on failed cd -s to relative path
[zsh.git] / Completion / Unix / Type / _services
blob2965e0f3efb8ae318993047f3ead5e77888696f7
1 #autoload
3 local -a inits xinetds alls
4 local expl ret=1
6 if chkconfig --list > /dev/null 2>&1; then
7   alls=( ${(f)"$(LANGUAGE=C LANG=C LC_ALL=C chkconfig --list)"} )
8   inits=( ${${${alls[1,(r)xinetd based*]}[1,-2]}/%[[:space:]]*/} )
9   xinetds=( ${${${${alls[(r)xinetd based*,-1]}[2,-1]}/#[[:space:]]#}/%:*} )
11   _alternative \
12     'init:init service:compadd -a inits' \
13     'xinetd:xinetd service:compadd -a xinetds' && ret=0
14 else
15   _wanted services expl service compadd "$@" - /etc/init.d/*(-*:t) && ret=0
18 return ret