[Toybox] sysctl musings.

Rob Landley rob at landley.net
Mon May 12 16:15:22 PDT 2014


You know, sysctl is actually a really badly specified program. Not the
recent submission, I mean the original one.

If you do something like this:

  sysctl net.unix.max_dgram_qlen kernel.sched_domain.cpu1

It lists the keys under there. That _implies_ that sysctl with no
arguments should show all keys, but instead it shows a usage message and
says "-a" (or -A) shows all keys. But if you do -a and a key, you get
the usage message (not even an error, just the usage message), and if
you put the -a at the end it says "-a" is an unknown key.

Next up, assigning keys. You can go "sudo sysctl
net.ipv4.conf.lo.forwarding=1" without specifying -w, because the =
tells it you're doing an assignment. The -w seems like a NOP, except:

  $ sysctl -w net.ipv4.conf.lo.forwarding
  error: "net.ipv4.conf.lo.forwarding" must be of the form name=value

I.E. that option exists to cause errors.

Next up, "-n". With grep the _default_ behavior is to print just the
matches when searching a single file, and to print the filename when
searching multiple files. Here, the default is "don't work in scripts",
and then you add options to work in scripts.

Sigh. Yeah, in the absence of any kind of spec we probably have to match
this behavior, and the submitted version does a decent job of that.
But... ow.

Rob

 1399936522.0


More information about the Toybox mailing list