Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: a compdef for FreeBSD's sysctl(8) command

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

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.


#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)'
    _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'

This message has been checked for all known viruses by the 
MessageLabs Virus Scanning Service. For further information visit

Messages sorted by: Reverse Date, Date, Thread, Author