zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <opk@u.genie.co.uk>
To: zsh-workers@sunsite.dk
Cc: Akinori MUSHA <knu@iDaemons.org>
Subject: PATCH: Re: a compdef for FreeBSD's sysctl(8) command
Date: Thu, 05 Jul 2001 12:04:02 +0100	[thread overview]
Message-ID: <3B4449A2.3B570F35@u.genie.co.uk> (raw)
In-Reply-To: <200107040846.KAA11447@beta.informatik.hu-berlin.de>

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


      reply	other threads:[~2001-07-05 11:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-03  5:52 Akinori MUSHA
2001-07-03  6:31 ` Andrej Borsenkow
2001-07-03 10:49 ` Oliver Kiddle
2001-07-03 11:16   ` Akinori MUSHA
2001-07-03 16:28     ` Bart Schaefer
2001-07-03 18:27       ` Akinori MUSHA
2001-07-04  8:46       ` Sven Wischnowsky
2001-07-05 11:04         ` Oliver Kiddle [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3B4449A2.3B570F35@u.genie.co.uk \
    --to=opk@u.genie.co.uk \
    --cc=knu@iDaemons.org \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).