Surprising command line options handling

Daniele Nicolodi daniele at
Tue Feb 24 00:59:07 CET 2015

On 24/02/15 00:19, Doug Barton wrote:
> On 2/23/15 2:51 PM, Daniele Nicolodi wrote:
>> Hello,
>> I've been struggling quite a long while today trying to understand why
>> the following command does not do what I expected:
>> gpg --export-secret-subkeys 41E999D7! \
>>      --export-options export-reset-subkey-passwd
>> It does not reset the password on the exported subkey.
>> After some head scratching I recognized that gpg stop parsing arguments
>> when it encounters the key id and ignores what follows.
> That's not 100% accurate, but I won't quibble. :)
> The man page makes it very clear that the format is as follows:
> gpg2 [--homedir dir] [--options file] [options] command [args]
> options come before commands, and anything after the command is 
> interpreted as an argument to the command.

In retrospect this is quite clear.

However, the ordering is not really enforced: this

gpg --export-secret-subkeys \
    --export-options export-reset-subkey-passwd --armor \
    whatever 41E999D7!

or this

gpg --export-secret-subkeys \
    --export-options export-reset-subkey-passwd whatever --armor \

appear to be valid command lines.

I find it surprising that unrecognized tokens are simply ignored.
Wouldn't it be preferable to error out, at least on unrecognized options?


More information about the Gnupg-users mailing list