[Toybox] Allow --help after other arguments?

Rob Landley rob at landley.net
Thu Jun 10 19:22:20 PDT 2021


On 6/9/21 9:00 PM, Ryan Prichard wrote:
> It seems to have broken --help when invoking toybox explicitly:

Because you asked it to. There's a reason it wasn't doing it from any position
before.

> $ ./toybox ls --help
> <shows same output as "./toybox --help" rather than the "toybox ls" usage.>

ls one two three --help: produces help output for ls.
toybox ls banana --help potato: produces help output for toybox.

You want me to special case toybox to NOT accept --help in any but the first
position? Except you presumably also want:

toybox toybox toybox toybox ls --help

to show the help for ls. And DON'T want "chroot dir ls --help" to show help
output for chroot. (Or time. Or nice. Or nohup...)

> Are we concerned about interpreting "data" arguments as the --help flag? e.g.:

Again, not a thing that could happen under the previous design...

> $ ./rm -- --help
> <prints usage rather than remove the file named "--help">

Yeah, that's a problem.

> $ ./tar -c README > --help && tar -tvf --help
> -rw-r----- rprichard/primarygroup 6306 2021-06-08 19:10 README

The > --help is going to get eaten by the shell (argument to the redirect)
before the tar command ever gets run, so it doesn't matter what toybox does there.

As for "tar -tvf --help", yeah, that's a problem.

You've convinced me to revert the patch I did. It makes things worse. There is a
"help" command, and there's a "man" command in pending I gave up trying to clean
up after I threw away what I'd done three times because somebody else had yet
another patch to it. (It's now behind "dd" in the to-clean-up list.)

The reason that --help isn't in the argument parsing plumbing is because then
commands that don't have arguments wouldn't support --help, not without the
argument parsing plumbing being unable to drop out when building small binaries.

> $ ./tar -c README > --help && ./tar -tvf --help
> <prints "toybox tar" usage with the new --help behavior. previously toybox
> behaved like GNU tar above.>

And now you know why I had it the way it was. It sounds like what you're saying
is that the toysh "alias" command should be --help aware for builtins.

Rob



More information about the Toybox mailing list