Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: a compdef for FreeBSD's sysctl(8) command
- X-seq: zsh-workers 15223
- From: Oliver Kiddle <opk@xxxxxxxxxxxxx>
- To: Akinori MUSHA <knu@xxxxxxxxxxxx>
- Subject: Re: a compdef for FreeBSD's sysctl(8) command
- Date: Tue, 03 Jul 2001 11:49:02 +0100
- Cc: zsh-workers@xxxxxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <86y9q6d0fz.wl@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Sender: kiddleo@xxxxxxxxxxxxxxxx
Akinori MUSHA wrote:
> Attached is a compdef for FreeBSD's sysctl(8) command which gets or
> sets kernel state. It was reviewed in a public mailing list.
>
> Would you please merge this?
Thanks, I'll merge that a bit later.
First though, I've just tried to adapt it to also work for Linux. I
also replaced your function with a substitution which I think should
do the same thing so I would appreciate if you could check that the
updated function below still works.
I don't suppose that $OSTYPE on FreeBSD includes any of the FreeBSD
version. It is just that it is a tiny bit faster to check than
`uname -sr`?
If `sysctl -A' or `sysctl -aN' is run as a non-root user, do you get
any output to stderr (you do on Linux)? If so, we need to add a
redirection.
Does anyone on zsh-workers mind if I put this on the stable branch.
Mainly because I suspect the FreeBSD folks would otherwise be
maintaining it as a patch for their port.
Oliver
#compdef sysctl
case `uname -sr` 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\ [5-9].*)
_arguments -s \
'-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)'
;;
Linux*)
_arguments -A "-*" \
'-n[show only variable values]' \
'(-n -p -a -A)-w[write mode]' \
'(-n -w -a -A *)-p[specify file to load sysctl settings from]:file:_files' \
'(-n -w -p -A *)-a[list all]' \
'(-n -w -p -a *)-A[list all in table form]' \
'(-n -p -a -A)*:sysctl variable:_files -W /proc/sys'
;;
esac
_____________________________________________________________________
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