Surprising command line options handling
daniele at grinta.net
Tue Feb 24 12:24:09 CET 2015
On 24/02/15 09:34, Werner Koch wrote:
>> I find it surprising that unrecognized tokens are simply ignored.
>> Wouldn't it be preferable to error out, at least on unrecognized options?
> GnuPG does not follow the common GNU model of interchangeable options
> and args. It is modeled like a classic Unix tool. Using the special
> option '--' indicates that everything what follows are args and using
> this is suggested to avoid args beeing interpreted as options.
> No, we can't error out on an arg which looks like an option because that
> may actually be a valid argument.
thank for your answer. Trying to better understand gnupg command line
argument parsing I found that the real confusing thing is that arguments
can be silently ignored:
gpg --list-keys foo
results in an error if there is no key matching "foo", however
gpg --list-keys 41E999D7 foo
does not result in an error and the fact that "foo" does not match any
is not signaled to the user, if there is a key that matches "41E999D7".
I see that in the 2.1 branch there is indeed a check and a warning for
arguments that look like options (start with "--") so I must not be the
only one that found this confusing :)
Why do not error out if an argument cannot be used to identify a key? I
think that signaling to the user that one part of the command line has
not been successfully interpreted is good practice.
More information about the Gnupg-users