From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28330 invoked from network); 6 May 2002 07:15:37 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 6 May 2002 07:15:37 -0000 Received: (qmail 4723 invoked by alias); 6 May 2002 07:15:31 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 17076 Received: (qmail 4711 invoked from network); 6 May 2002 07:15:30 -0000 From: Borsenkow Andrej To: "'Zsh hackers list'" Subject: RE: PATCH: _chkconfig, _service Date: Mon, 6 May 2002 11:15:16 +0400 Message-ID: <6134254DE87BD411908B00A0C99B044F02E89A36@mowd019a.mow.siemens.ru> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0031_01C1F4EF.4E1D51F0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.3416 In-Reply-To: <20020419162253.GA25529@logica.com> x-mimeole: Produced By Microsoft MimeOLE V6.00.2600.0000 Importance: Normal This is a multi-part message in MIME format. ------=_NextPart_000_0031_01C1F4EF.4E1D51F0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit > On Fri, Apr 19, 2002 at 12:23:18PM +0400, Borsenkow Andrej wrote: > > This adds support for chkconfig and service. I put them in RedHat > > because they originate there, but I have only Mandrake so actual usage > > Have you noticed that an _chkconfig already exists? Not in the > RedHat directory because it also handles IRIX. > Oops. I mostly now do this stuff on Mandrake under stock 4.0.4. Really, we need 4.0.5 if even for new completions. Good, this adds _services helper that tries to use chkconfig --list if available; it also accounts for xinetd support in chkconfig. It also makes _init_d to work for plain service name and uses them where appropriate. O.K.? I tried to preserve indentation style :-) -andrej ------=_NextPart_000_0031_01C1F4EF.4E1D51F0 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/.distfiles=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/Redhat/Command/.distfiles,v=0A= retrieving revision 1.1=0A= diff -u -r1.1 .distfiles=0A= --- Completion/Redhat/Command/.distfiles 2 Apr 2001 12:43:15 -0000 = 1.1=0A= +++ Completion/Redhat/Command/.distfiles 6 May 2002 07:13:49 -0000=0A= @@ -1,4 +1,5 @@=0A= DISTFILES_SRC=3D'=0A= .distfiles=0A= _rpm=0A= +_service=0A= '=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 6 May 2002 07:13:49 -0000=0A= @@ -0,0 +1,22 @@=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= +# we are interested in init service only=0A= +local ctx=3D"${curcontext/%[^:]#:[^:]#/argument-1:}"=0A= +zstyle -T ":completion:$ctx" tag-order && \=0A= + zstyle ":completion:$ctx" tag-order init -=0A= +=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:_services' \=0A= + '*::service argument: _init_d'=0A= +=0A= Index: Completion/Unix/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: /cvsroot/zsh/zsh/Completion/Unix/Command/_chkconfig,v=0A= retrieving revision 1.1=0A= diff -u -r1.1 _chkconfig=0A= --- Completion/Unix/Command/_chkconfig 14 Jan 2002 14:17:51 -0000 = 1.1=0A= +++ Completion/Unix/Command/_chkconfig 6 May 2002 07:13:49 -0000=0A= @@ -9,13 +9,8 @@=0A= '(-)--level[specify runlevels to apply to]:-:_values -s "" "run = levels" 1 2 3 4 5 6 7' \=0A= '(- 2)--add[add new service]' \=0A= '(- 2)--del[remove service from chkconfig management]' \=0A= - '1:service name:->services' \=0A= + '1:service name:_services' \=0A= '2:state:(on off reset)' && ret=3D0=0A= -=0A= - if [[ -n "$state" ]]; then=0A= - _wanted services expl 'system service' \=0A= - compadd ${${${(f)"$($words[1] --list)"}%%[ :]*}##$'\t'*} && = ret=3D0=0A= - fi=0A= ;;=0A= irix*)=0A= _arguments -C \=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 6 May 2002 07:13:49 -0000=0A= @@ -1,21 +1,24 @@=0A= #compdef -P */(init|rc[0-9S]#).d/*=0A= =0A= -local magic cmds what=0A= +local magic cmds what script=0A= =0A= # This should probably be system specific...=0A= =0A= +script=3D$words[1]=0A= +[[ $script =3D */* ]] || script=3D/etc/init.d/$script=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= +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)"$(< = $words[1])"}:#[[:blank:]]#(\'|)[a-z_|]##(\'|)\)}}//[^a-z_]} )=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= Index: Completion/Unix/Type/.distfiles=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/Type/.distfiles,v=0A= retrieving revision 1.8=0A= diff -u -r1.8 .distfiles=0A= --- Completion/Unix/Type/.distfiles 10 Apr 2002 05:24:29 -0000 1.8=0A= +++ Completion/Unix/Type/.distfiles 6 May 2002 07:13:49 -0000=0A= @@ -9,5 +9,5 @@=0A= _groups _perl_basepods _signals = _users_on=0A= _hosts _perl_builtin_funcs _tar_archive = _time_zone=0A= _file_systems _net_interfaces _terminals = _locales=0A= -_java_class=0A= +_java_class _services=0A= '=0A= Index: Completion/Unix/Type/_services=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/_services=0A= diff -N Completion/Unix/Type/_services=0A= --- /dev/null 1 Jan 1970 00:00:00 -0000=0A= +++ Completion/Unix/Type/_services 6 May 2002 07:13:49 -0000=0A= @@ -0,0 +1,23 @@=0A= +#autoload=0A= +=0A= +local -a inits xinetds alls=0A= +local expl ret=3D1=0A= +=0A= +if chkconfig --list > /dev/null 2>&1; then=0A= + alls=3D( ${(f)"$(LANGUAGE=3DC LANG=3DC LC_ALL=3DC chkconfig = --list)"} )=0A= + inits=3D( ${${${alls[1,(r)xinetd based*]}[1,-2]}/%[[:space:]]*/} = )=0A= + xinetds=3D( ${${${${alls[(r)xinetd = based*,-1]}[2,-1]}/#[[:space:]]#}/%:*} )=0A= +else=0A= + inits=3D( /etc/init.d/*(:t) )=0A= +fi=0A= +=0A= +_tags init xinetd=0A= +=0A= +while _tags; do=0A= + _requested init expl 'init services' \=0A= + compadd -a inits && ret=3D0=0A= + _requested xinetd expl 'xinetd services' \=0A= + compadd -a xinetds && ret=3D0=0A= +done=0A= +=0A= +return $ret=0A= ------=_NextPart_000_0031_01C1F4EF.4E1D51F0--