From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21478 invoked from network); 26 Feb 2001 10:13:40 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 26 Feb 2001 10:13:40 -0000 Received: (qmail 4305 invoked by alias); 26 Feb 2001 10:13:35 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13531 Received: (qmail 4282 invoked from network); 26 Feb 2001 10:13:29 -0000 Date: Mon, 26 Feb 2001 11:13:19 +0100 (MET) Message-Id: <200102261013.LAA28626@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.dk In-reply-to: Fletch's message of 23 Feb 2001 10:07:14 -0500 Subject: Re: completion function for apachectl Fletch wrote: > This completes for apachectl (a utility that comes with apache > to do things such as restarting apache, syntax checking it's > configuration file, and the like). Thanks for writing a new completion function. Just some comments: > +#compdef apachectl > + > +local curcontext="$curcontext" state line commands ret=1 > +typeset -A opt_args Most of these need only be made local if `_arguments' is used with a `->state' action. > +commands=( start startssl stop restart fullstatus status > + graceful configtest help ) Using an extra array maybe slightly more readable, but in a function as simple as this one... > +_arguments \ > + ":Choose an action:($commands)" && ret=0 > + > +return $ret No need for `&& ret=0 ... return $ret'. Without a `return' the return value of a function is the return value of the last command in it. And using `_arguments' is only really useful if there is some more to do (options, multiple arguments,...) -- otherwise it's quite expensive. One could get the same with the simpler: #compdef apachectl local expl if [[ CURRENT -eq 2 ]]; then _wanted commands expl command compadd \ start startssl stop restart fullstatus status graceful configtest help else _message 'no more arguments' fi Hm. Since there are several commands (and scripts[1]) that only get one command as argument, I'm almost tempted to add a generic version of the above as a utility function. Opinions? Bye Sven [1] Wasn't there a request for init-script completion on the debian list? -- Sven Wischnowsky wischnow@informatik.hu-berlin.de