[Toybox] Note about nbd-client (command name with a dash).
Rob Landley
rob at landley.net
Sun Jul 6 18:16:18 PDT 2014
My tree is full of half-finished things, so I'm
finishing/testing/checking them in. One I've had lying around forever is
nbd-client, which I wrote a version of in 2010 and threw at busybox
because it was there and toybox was mothballed at the time.
The reason it's taken so long to port over is names with a dash in them
drive the macro infrastructure nuts, because you can't have a dash in a
symbol (I.E. "nbd-client_main()" isn't a valid function name).
The workaround I came up with is fairly awkward and not automated, so I
should explain it here:
What I did was implement the command as nbd_client with an underscore,
so the filename is nbd_client.c and it uses nbd_client_main() and so on.
But I didn't put any location components in the TOYFLAGs, which signals
the "./toybox --list" infrastructure to skip it. (You can call it by
that name if you know it's there, but when installing symlinks it gets
skipped. This was already there for shell builtins like cd and exit,
which shouldn't have symlinks.)
Then I have an OLDTOY() macro provide a second name, and this one is
TOYFLAG_USR|TOYFLAG_BIN and thus _does_ show up in the list. (The fact
OLDTOY doesn't need to use the name in symbols is also why I can have
":" be an OLDTOY for true, as another shell builtin.)
One problem with this is that "help -a" shows entries for both ":" and
"nbd_client" (so nbd-client basically shows up twice). That's because
shell builtins can have help entires (type "help cd" on your host, the
bash builtin has a help page. Yes there's "man" and "help" showing
different things, welcome to unix.)
I need to tweak the help infrastructure to let it know there are some
commands it shouldn't show help entries for. I also need to teach it
that "./toybox help mv" shouldn't show the cp help; right now oldtoy
doesn't provide different help entries. That needs some design work and
isn't something I can afford to spend time on today if I'm to get this
release out. :)
Rob
1404695778.0
More information about the Toybox
mailing list