From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12076 invoked from network); 19 Apr 2002 08:23:36 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 19 Apr 2002 08:23:36 -0000 Received: (qmail 22269 invoked by alias); 19 Apr 2002 08:23:30 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 17015 Received: (qmail 22256 invoked from network); 19 Apr 2002 08:23:28 -0000 From: Borsenkow Andrej To: "'Zsh hackers list'" Subject: PATCH: _chkconfig, _service Date: Fri, 19 Apr 2002 12:23:18 +0400 Message-ID: <001101c1e77b$776bed40$1fc1f2a3@mow.siemens.ru> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0012_01C1E79C.FE7D8D40" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.3416 x-mimeole: Produced By Microsoft MimeOLE V6.00.2600.0000 Importance: Normal This is a multi-part message in MIME format. ------=_NextPart_000_0012_01C1E79C.FE7D8D40 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit This adds support for chkconfig and service. I put them in RedHat because they originate there, but I have only Mandrake so actual usage may differ. Would anybody with RedHat check if it is correct for him and modify if needed (but please preserve current usage for Mandrake; you can test for Mandrake with /etc/mandrake-release). It adds a couple of helpers and modifies _init_d to use them. If there are no objections I commit them. -andrej ------=_NextPart_000_0012_01C1E79C.FE7D8D40 Content-Type: application/octet-stream; name="zsh-initscripts.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="zsh-initscripts.diff" Index: Completion/Redhat/Command/_chkconfig=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: Completion/Redhat/Command/_chkconfig=0A= diff -N Completion/Redhat/Command/_chkconfig=0A= --- /dev/null 1 Jan 1970 00:00:00 -0000=0A= +++ Completion/Redhat/Command/_chkconfig 19 Apr 2002 08:18:11 -0000=0A= @@ -0,0 +1,9 @@=0A= +#compdef chkconfig=0A= +=0A= +_arguments \=0A= + "(: --add --del --level)--list[list available services]:available = services:_init_scripts" \=0A= + "(: --add --list --level)--del[remove service]:available = services:_init_scripts" \=0A= + "(: --del --list --level)--add[add service]:available = services:_init_scripts" \=0A= + "(--add --del --list)--level[specify runlevel]:run level:(0 1 2 3 4 5 = 6 s)" \=0A= + ":service name:_init_scripts" \=0A= + ":state:(on off reset)"=0A= Index: Completion/Redhat/Command/_service=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: Completion/Redhat/Command/_service=0A= diff -N Completion/Redhat/Command/_service=0A= --- /dev/null 1 Jan 1970 00:00:00 -0000=0A= +++ Completion/Redhat/Command/_service 19 Apr 2002 08:18:11 -0000=0A= @@ -0,0 +1,15 @@=0A= +#compdef service=0A= +=0A= +# *:: for last argument looks more like a hack but it is=0A= +# the simplest way known to me to reset $words and keep=0A= +# _sub_command happy=0A= +=0A= +_arguments -s \=0A= + '(-d --debug)'{-d,--debug}'[turn debugging on]' \=0A= + '(- :)'{-h,--help}'[print usage]' \=0A= + '(- :)'{-v,--version}'[print version]' \=0A= + '(-)'{-f,--full-restart}'[restart service]' \=0A= + '(- :)'{-R,--full-restart-all}'[restart all services]' \=0A= + '(- :)'{-s,--status-all}'[print status of all services]' \=0A= + ':service name:_init_scripts' \=0A= + '*::service argument:{_initscript_argument $words[CURRENT]}'=0A= Index: Completion/Unix/Command/_init_d=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_init_d,v=0A= retrieving revision 1.2=0A= diff -u -r1.2 _init_d=0A= --- Completion/Unix/Command/_init_d 30 Jan 2002 03:38:30 -0000 1.2=0A= +++ Completion/Unix/Command/_init_d 19 Apr 2002 08:18:11 -0000=0A= @@ -1,23 +1,3 @@=0A= #compdef -P */(init|rc[0-9S]#).d/*=0A= =0A= -local magic cmds what=0A= -=0A= -# This should probably be system specific...=0A= -=0A= -# If the file starts with `#!' we hope that this is a shell script=0A= -# and get lines looking like foo|bar) with the words in = $what.=0A= -=0A= -what=3D'(st(art|op|atus)|(force-|)re(start|load)|debug_(up|down)|dump(|= _stats)|add|delete|clean|list)'=0A= -=0A= -[[ -f $words[1] ]] && read -u0k 2 magic < $words[1] && [[ $magic =3D = '#!' ]] &&=0A= - cmds=3D( ${${(j:|:s:|:)${(M)${(f)"$(< = $words[1])"}:#[[:blank:]]#\'#${~what}(\|${~what})#\'#\)*}}//[^a-z_-]} = )=0A= -=0A= -# This would be the pattern to use every line of the form = foo).=0A= -# Some people say this might match too many lines...=0A= -#=0A= -# cmds=3D( ${${(j:|:s:|:)${(M)${(f)"$(< = $words[1])"}:#[[:blank:]]#(\'|)[a-z_|]##(\'|)\)}}//[^a-z_]} )=0A= -=0A= -(( $#cmds )) || zstyle -a ":completion:${curcontext}:commands" = commands cmds ||=0A= - cmds=3D(start stop)=0A= -=0A= -_sub_commands $cmds=0A= +_initscript_argument $words[CURRENT]=0A= Index: Completion/Unix/Type/_init_scripts=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: Completion/Unix/Type/_init_scripts=0A= diff -N Completion/Unix/Type/_init_scripts=0A= --- /dev/null 1 Jan 1970 00:00:00 -0000=0A= +++ Completion/Unix/Type/_init_scripts 19 Apr 2002 08:18:11 -0000=0A= @@ -0,0 +1,16 @@=0A= +#autoload=0A= +=0A= +local expl=0A= +local -a services=0A= +=0A= +# exclude backup files and RPM leftovers=0A= +services=3D(/etc/init.d/*~(*~|*.orig|*.rpmnew|*.rpmsave|*.rpmorig)(N:t)= )=0A= +=0A= +# remove those that are known to not be real initscripts=0A= +if [[ -f /etc/mandrake-release ]]; then=0A= + = services=3D(${services:#(functions|mandrake_firstime|mandrake_everytime|= mandrake_consmap)})=0A= +elif [[ -f /etc/redhat-release ]]; then=0A= + services=3D(${services:#functions})=0A= +fi=0A= +=0A= +_wanted initscripts expl 'init scripts' compadd "$@" -a services=0A= Index: Completion/Unix/Type/_initscript_argument=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: Completion/Unix/Type/_initscript_argument=0A= diff -N Completion/Unix/Type/_initscript_argument=0A= --- /dev/null 1 Jan 1970 00:00:00 -0000=0A= +++ Completion/Unix/Type/_initscript_argument 19 Apr 2002 08:18:11 = -0000=0A= @@ -0,0 +1,33 @@=0A= +#autoload=0A= +=0A= +local magic cmds what script=0A= +=0A= +(( $# =3D=3D 1 )) || return 1=0A= +=0A= +# This should probably be system specific...=0A= +=0A= +if [[ -f $1 ]]; then=0A= + script=3D$1=0A= +elif [ -f /etc/init.d/$1 ]]; then=0A= + script=3D/etc/init.d/$1=0A= +fi=0A= +=0A= +(( $#script )) || return 1=0A= +=0A= +# If the file starts with `#!' we hope that this is a shell script=0A= +# and get lines looking like foo|bar) with the words in = $what.=0A= +=0A= +what=3D'(st(art|op|atus)|(force-|)re(start|load)|debug_(up|down)|dump(|= _stats)|add|delete|clean|list)'=0A= +=0A= +read -u0k 2 magic < $script && [[ $magic =3D '#!' ]] &&=0A= + cmds=3D( ${${(j:|:s:|:)${(M)${(f)"$(< = $script)"}:#[[:blank:]]#(\'|)${~what}(|${~what})#(\'|)\)}}//[^a-z_]} = )=0A= +=0A= +# This would be the pattern to use every line of the form = foo).=0A= +# Some people say this might match too many lines...=0A= +#=0A= +# cmds=3D( ${${(j:|:s:|:)${(M)${(f)"$(< = $script)"}:#[[:blank:]]#(\'|)[a-z_|]##(\'|)\)}}//[^a-z_]} )=0A= +=0A= +(( $#cmds )) || zstyle -a ":completion:${curcontext}:commands" = commands cmds ||=0A= + cmds=3D(start stop)=0A= +=0A= +_sub_commands $cmds=0A= ------=_NextPart_000_0012_01C1E79C.FE7D8D40--