[Toybox] Allow --help after other arguments?

Ryan Prichard rprichard at google.com
Fri Jun 11 14:51:57 PDT 2021

On Thu, Jun 10, 2021 at 7:05 PM Rob Landley <rob at landley.net> wrote:

> 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...)

Yeah, I think my ideal would be for --help to apply to the last
(sub)command preceding it. e.g. When it appears after a subcommand name, it
would be parsed like any other subcommand flag. For "time", flag parsing
(for -p and -v) seems to stop at the first non-hyphenated argument.

Aside: "toybox toybox toybox toybox ls" doesn't seem to work for me:

$ toybox toybox toybox toybox ls --help
toybox: Unknown command toybox (see "toybox --help")

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.)

Yeah, I agree with reverting the patch.

> 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.

I'm wondering when it's useful to drop the argument parsing plumbing. Is
there a configuration where CFG_TOYBOX is off, and there is one binary for
one command? Most of the commands take arguments, so I'd think most builds
of the toybox binary would need some amount of the plumbing.

> $ ./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.

Ah, I don't think I'd make a special case for alias... not sure how that
would work?

So... I don't actually use alias on Android devices. I had suggested it as
an example that might motivate "ls -l --help" more strongly than
convenience and expectation. I'm happy enough just editing the --help into
the right place on the command line.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20210611/6e0a035b/attachment.html>

More information about the Toybox mailing list