From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13388 invoked from network); 15 May 2001 15:07:36 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 15 May 2001 15:07:36 -0000 Received: (qmail 1060 invoked by alias); 15 May 2001 15:07:30 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 14355 Received: (qmail 991 invoked from network); 15 May 2001 15:07:27 -0000 Sender: kiddleo Message-ID: <3B014622.7EE4888@u.genie.co.uk> Date: Tue, 15 May 2001 16:07:14 +0100 From: Oliver Kiddle X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.15 i686) X-Accept-Language: en MIME-Version: 1.0 To: zsh-workers@sunsite.dk Subject: Re: PATCH: rmmod/modprobe -r completion References: <20010514222601.A18298@dman.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Clint Adams wrote: > > This lacks all the other options to modprobe, and ignores > insmod, but it seemed silly to just do rmmod and not have it work > for modprobe -r. This will be useful, cheers. > Index: Completion/Unix/Command/_modutils This is probably the first thing which really could be in a Linux directory. It's probably best to move it later once we have others though. > +if [[ -f /proc/modules ]]; then > + loaded=(${${(f)"$( +elif [[ -x /sbin/lsmod ]]; then > + loaded=(${${${(f)"$( +compadd -a loaded > +return 0 I also changed this to use _wanted so we get a description. I removed the return statement because it should return 1 if the loaded array is created but empty. > + '*:loaded module:_modutils_loaded_modules' Hmm, this is fine but I'd have used a state or cached the loaded array and passed it to _arguments. Which is more efficient - functions declared in the autoloaded functions or states? Oliver Index: Completion/Unix/Command/_modutils =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_modutils,v retrieving revision 1.1 diff -u -r1.1 _modutils --- Completion/Unix/Command/_modutils 2001/05/15 02:32:53 1.1 +++ Completion/Unix/Command/_modutils 2001/05/15 15:01:39 @@ -1,19 +1,18 @@ #compdef modprobe rmmod -local loaded +local expl loaded _modutils_loaded_modules() { -if [[ -f /proc/modules ]]; then +if [[ -r /proc/modules ]]; then loaded=(${${(f)"$(