From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16763 invoked from network); 4 Oct 2009 18:13:54 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from new-brage.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.254.104) by ns1.primenet.com.au with SMTP; 4 Oct 2009 18:13:54 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 98750 invoked from network); 4 Oct 2009 18:13:47 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 4 Oct 2009 18:13:47 -0000 Received: (qmail 4608 invoked by alias); 4 Oct 2009 18:13:44 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 27308 Received: (qmail 4588 invoked from network); 4 Oct 2009 18:13:43 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 4 Oct 2009 18:13:43 -0000 Received: from mtaout01-winn.ispmail.ntl.com (mtaout01-winn.ispmail.ntl.com [81.103.221.47]) by bifrost.dotsrc.org (Postfix) with ESMTP id DE7D6801E2BF for ; Sun, 4 Oct 2009 20:13:35 +0200 (CEST) Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20091004181334.YOBK17029.mtaout01-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com> for ; Sun, 4 Oct 2009 19:13:34 +0100 Received: from pws-pc ([82.6.98.90]) by aamtaout02-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20091004181334.NHES21638.aamtaout02-winn.ispmail.ntl.com@pws-pc> for ; Sun, 4 Oct 2009 19:13:34 +0100 Date: Sun, 4 Oct 2009 19:13:29 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: Completion function patches Message-ID: <20091004191329.298ced0a@pws-pc> In-Reply-To: <4AC89D4E.6050608@gmail.com> References: <4AC89D4E.6050608@gmail.com> X-Mailer: Claws Mail 3.7.2 (GTK+ 2.16.6; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Cloudmark-Analysis: v=1.0 c=1 a=pGLkceISAAAA:8 a=NLZqzBF-AAAA:8 a=isnBRqFlK0HdautpIgQA:9 a=o0CpnDDgrfZIKx1x8SEQ2Ti1I54A:4 a=MSl-tDqOz04A:10 a=_dQi-Dcv4p4A:10 X-Virus-Scanned: ClamAV 0.94.2/9866/Sat Oct 3 16:49:15 2009 on bifrost X-Virus-Status: Clean On Sun, 04 Oct 2009 08:04:14 -0500 Edgar Merino wrote: > Hello, I recently had to work with two utility functions for the > completion system: _services and _init_d. I'm running archlinux and here > services are under the /etc/rc.d directory, instead of the default > directory that appears in those 2 scripts (/etc/init.d). Attached I > provide you with pataches for both scripts, so that they work fine when > running a system with an init framework similar to mine. Please let me > know if I should do something else to contribute this code. Thanks, I'll commit the following. Index: Completion/Unix/Command/_init_d =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_init_d,v retrieving revision 1.8 diff -u -r1.8 _init_d --- Completion/Unix/Command/_init_d 8 Oct 2007 08:40:14 -0000 1.8 +++ Completion/Unix/Command/_init_d 4 Oct 2009 18:10:02 -0000 @@ -7,7 +7,20 @@ # This should probably be system specific... script=$words[1] -[[ $script = */* ]] || script=/etc/init.d/$script +if [[ $script != */* ]]; then + local -a scriptpath + local dir + # Known locations of init scripts + # C.f. Unix/Type/_services + scriptpath=(/etc/init.d /etc/rc.d /etc/rc.d/init.d) + + for dir in $scriptpath; do + if [[ -f $dir/$script ]]; then + script=$dir/$script + break + fi + done +fi # If the file starts with `#!' we hope that this is a shell script # and get lines looking like foo|bar) with the words in $what. Index: Completion/Unix/Type/_services =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_services,v retrieving revision 1.4 diff -u -r1.4 _services --- Completion/Unix/Type/_services 8 Jun 2005 12:45:36 -0000 1.4 +++ Completion/Unix/Type/_services 4 Oct 2009 18:10:02 -0000 @@ -12,7 +12,19 @@ 'init:init service:compadd -a inits' \ 'xinetd:xinetd service:compadd -a xinetds' && ret=0 else - _wanted services expl service compadd "$@" - /etc/init.d/*(-*:t) && ret=0 + local -a scriptpath + local dir + # Known locations of init scripts + # C.f. Unix/Commands/_init_d + scriptpath=(/etc/init.d /etc/rc.d /etc/rc.d/init.d) + + for dir in $scriptpath; do + if [[ -d $dir ]]; then + break + fi + done + _wanted services expl service compadd "$@" - $dir/*(-*:t) && + ret=0 fi return ret -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/