From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4158 invoked from network); 5 Jul 2001 11:04:45 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 5 Jul 2001 11:04:45 -0000 Received: (qmail 29539 invoked by alias); 5 Jul 2001 11:03:42 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 15252 Received: (qmail 29524 invoked from network); 5 Jul 2001 11:03:42 -0000 X-VirusChecked: Checked Sender: kiddleo@cav.logica.co.uk Message-ID: <3B4449A2.3B570F35@u.genie.co.uk> Date: Thu, 05 Jul 2001 12:04:02 +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 CC: Akinori MUSHA Subject: PATCH: Re: a compdef for FreeBSD's sysctl(8) command References: <200107040846.KAA11447@beta.informatik.hu-berlin.de> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sven Wischnowsky wrote: > I'm sure that I'm not the only one who would like to see exclusion lists > added for the BSD-parts, though, but that can be patched in later, of > course. I carried on discussion of the sysctl completion with Akinori Musha off the list and between us we have made a few improvements. The exclusion lists are there and it also now uses _multi_parts for the variables. One other issue was whether to cache the list of variables. For FreeBSD 4.x, it apparently takes quite a long time to generate the list because sysctl -A extracts all the variables' values. The trouble is that the list of variables changes if kernel modules are loaded/unloaded. As a slightly crude solution, the patch below clears the cache in _kld - the completion for kldload/kldunload. I think this is a reasonable way but am not totally happy so I'd be interested if anyone else has any view on this (and I won't commit the change just yet). Oliver Index: Completion/BSD/Command/_kld =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/BSD/Command/_kld,v retrieving revision 1.1 diff -u -r1.1 _kld --- Completion/BSD/Command/_kld 2001/04/02 12:21:07 1.1 +++ Completion/BSD/Command/_kld 2001/07/05 10:39:12 @@ -21,6 +21,8 @@ } _kld() { + unset _cache_sysctlvars + case "$service" in kldload) _arguments -s \ Index: Completion/Unix/Command/_sysctl =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_sysctl,v retrieving revision 1.1 diff -u -r1.1 _sysctl --- Completion/Unix/Command/_sysctl 2001/07/03 14:32:12 1.1 +++ Completion/Unix/Command/_sysctl 2001/07/05 10:39:12 @@ -1,25 +1,28 @@ #compdef sysctl case $OSTYPE in - freebsd[0-4]*) - _arguments -s \ - '-a[list all]' \ - '-A[show all opaques (values suppressed)]' \ - '-b[binary output]' \ - '-n[show only variable values]' \ - '-w[write mode]' \ - '-X[show all opaques (entire values)]' \ - "*:sysctl variable:compadd ${words[(r)-w]:+-S =} $(sysctl -A | sed 's/:.*//')" + freebsd[0-4].*) + : ${(A)_cache_sysctlvars:=${${$(sysctl -A):#[^a-z]*}%%:*}} + _arguments -s -A "-*" \ + '(-w -X *)-a[list all]' \ + '(-w -X *)-A[show all opaques (values suppressed)]' \ + '(-w)-b[binary output]' \ + '(-w)-n[show only variable values]' \ + '(-a -A -b -n -X)-w[write mode]' \ + '(-a -A -w *)-X[show all opaques (entire values)]' \ + '(-a -A -X)*:sysctl variable:_multi_parts ${words[(r)-w]:+-S=} -i . _cache_sysctlvars' ;; - freebsd[5-9]*) - _arguments -s \ - '-a[list all]' \ + freebsd[5-9].*) + local -a sysctlvars + sysctlvars=( $(sysctl -aN) ) + _arguments -s -A "-*" \ + '(*)-a[list all]' \ '-b[binary output]' \ - '-N[show only variable names]' \ - '-n[show only variable values]' \ - '-o[show opaques as well (values suppressed)]' \ - '-x[show opaques as well (entire values)]' \ - '*:sysctl variable:compadd -S "" - $(sysctl -aN)' + '(-n)-N[show only variable names]' \ + '(-N)-n[show only variable values]' \ + '(-x)-o[show opaques as well (values suppressed)]' \ + '(-o)-x[show opaques as well (entire values)]' \ + '(-a)*:sysctl variable:_multi_parts -i . sysctlvars' ;; linux*) _arguments -A "-*" \ _____________________________________________________________________ This message has been checked for all known viruses by the MessageLabs Virus Scanning Service. For further information visit http://www.messagelabs.com/stats.asp