2001-03-18 20:55:12 +01:00
|
|
|
#compdef -P */(init|rc[0-9S]#).d/*
|
2001-02-26 16:05:37 +01:00
|
|
|
|
2001-03-08 11:17:03 +01:00
|
|
|
local magic cmds what
|
|
|
|
|
2001-02-26 16:05:37 +01:00
|
|
|
# This should probably be system specific...
|
|
|
|
|
2001-03-08 11:17:03 +01:00
|
|
|
# If the file starts with `#!' we hope that this is a shell script
|
|
|
|
# and get lines looking like <space>foo|bar) with the words in $what.
|
|
|
|
|
2001-03-18 20:55:12 +01:00
|
|
|
what='(st(art|op|atus)|(force-|)re(start|load)|debug_(up|down)|dump(|_stats)|add|delete|clean|list)'
|
2001-03-08 11:17:03 +01:00
|
|
|
|
|
|
|
read -u0k 2 magic < $words[1] && [[ $magic = '#!' ]] &&
|
|
|
|
cmds=( ${${(j:|:s:|:)${(M)${(f)"$(< $words[1])"}:#[[:blank:]]#(\'|)${~what}(|${~what})#(\'|)\)}}//[^a-z_]} )
|
|
|
|
|
|
|
|
# This would be the pattern to use every line of the form <space>foo).
|
|
|
|
# Some people say this might match too many lines...
|
|
|
|
#
|
|
|
|
# cmds=( ${${(j:|:s:|:)${(M)${(f)"$(< $words[1])"}:#[[:blank:]]#(\'|)[a-z_|]##(\'|)\)}}//[^a-z_]} )
|
|
|
|
|
2001-03-23 13:44:21 +01:00
|
|
|
(( $#cmds )) || zstyle -a ":completion:${curcontext}:commands" commands cmds ||
|
|
|
|
cmds=(start stop)
|
2001-03-08 11:17:03 +01:00
|
|
|
|
|
|
|
_sub_commands $cmds
|