[Toybox] --help

Jeremy Huntwork jhuntwork at lightcubesolutions.com
Fri Apr 5 13:12:18 PDT 2013


Hi, I'm a bit confused about how help text should operate. To me it would make sense to be a universal option which toybox handled for every command, but I'm seeing unexpected results.

For example:

toybox # ln -s toybox sha1sum
toybox # ./sha1sum
^C

OK, so sha1sum is expecting a file name as the first argument, seems reasonable. But doesn't it allow specific keywords?

toybox # ./sha1sum --help
sha1sum: --help: No such file or directory
toybox # ./sha1sum -h
sha1sum: -h: No such file or directory
toybox # ./sha1sum help
sha1sum: help: No such file or directory

Guess not. Maybe toybox does?

toybox # ./toybox help sha1sum
usage: md5sum [FILE]...

Calculate md5 hash for each input file, reading from stdin if none.
Output one hash (16 hex digits) for each input file, followed by
filename.

OK, good, but it's the wrong help text, apparently because md5sum and sha1sum share the same c file:

toybox # grep -A 7 help toys/lsb/md5sum.c
  help
    usage: md5sum [FILE]...

    Calculate md5 hash for each input file, reading from stdin if none.
    Output one hash (16 hex digits) for each input file, followed by
    filename.

config MD5SUM_SHA1SUM
--
  help
    usage: sha1sum [FILE]...

    calculate sha1 hash for each input file, reading from stdin if one.
    Output one hash (20 hex digits) for each input file, followed by
    filename.
*/

Also, I find it interesting on some commands that --help is an unknown flag, which then actually does what I want and spits out the usage:

toybox # ln -s toybox mkdir
toybox # ./mkdir --help
usage: mkdir [-p] [-m mode] [dirname...]
Create one or more directories.

-p  make parent directories as needed.
-m  set permissions of directory to mode.

mkdir: Unknown option help

Is there an acceptable way to standardize this across all toys?

JH


More information about the Toybox mailing list