On 9/9/21 17:01, Pádraig Brady wrote:
> If one updated getopt/argmatch to support something like:
>
>    prog=$(cksum --?algo=md5 && echo 'cksum -a md5' || echo 'md5sum')
>
> That would be a bit more elegant, but less widely supported.
>
> Anyway all this is a general issue,
> that cksum shouldn't be considering in isolation I think.

E.g. to get the possible options for `find -D` (debug), one can run:

  $ find -D help
  Valid arguments for -D:
  exec       Show diagnostic information relating to -exec, -execdir, -ok and 
-okdir
  ...
  all        Set all of the debug flags (but help)
  help       Explain the various -D options

So 'help' being an argument which is treated specially.
Not too bad IMO, and easy to remember.

(The code for parsing options in find(1) is not generic at all due to
the nature of old minus-something style, but this is just to demonstrate
how it looks to the user.)

Anyway, the possibility to programmatically parse the supported options
is a totally new and different aspect.  I'm not sure I would try to go
that way for portable scripts.

Have a nice day,
Berny

Reply via email to