Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Re: a compdef for FreeBSD's sysctl(8) command
- X-seq: zsh-workers 15252
- From: Oliver Kiddle <opk@xxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: PATCH: Re: a compdef for FreeBSD's sysctl(8) command
- Date: Thu, 05 Jul 2001 12:04:02 +0100
- Cc: Akinori MUSHA <knu@xxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <200107040846.KAA11447@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Sender: kiddleo@xxxxxxxxxxxxxxxx
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author