Subject: bug#7434: When an incorrect option is used before --help/--version, automake behaviour is inconsistent with that of other GNU programs.

From: Eric Blake <[email-masked]>
Date: Thu, 18 Nov 2010 08:55:39 -0700

On 11/18/2010 08:22 AM, Stefano Lattarini wrote:
> Severity: wishlist
> 
> Currently, automake and aclocal scan their command line looking for
> `--help' and `--version' even after an invalid option has been seen;
> and in case one of those two options is seen, it takes precedence
> even over error reporting about preceding invalid options.

GNU Coding Standards _only_ require that --help and --version be
recognized as the first argument, with no other arguments.  When
possible, recognizing --help and --version after other arguments, or
with other arguments afterwards, is nice, but there are no rules that
require that consistency.

> 
> But this is inconsistent with the behaviour of many others GNU/free
> programs; for example:
> 
>   $ m4 --version --no-such-option; echo \$? = $?
>   m4 (GNU M4) 1.4.14
>   $? = 0
> 
>   $ m4 --no-such-option --version; echo \$? = $?
>   m4: unrecognized option '--no-such-option'
>   Try `m4 --help' for more information.
>   $? = 1

m4 makes a single pass through its options, and gives up on the first
error (after all, how do we know that a future version of m4 might start
accepting 'm4 --do-this=--version', where --version is the argument of
the new --do-this option, at which point 'm4 --do-this --version' would
suddenly change behavior from printing versions to instead doing this).

Coreutils is also an interesting case study, as there are several idioms
used depending on POSIX restrictions on the utility in question.

For example:

$ /usr/bin/[ --help | head -n1
Usage: test EXPRESSION
$ /usr/bin/[ --help --oops
/usr/bin/[: missing `]'
$ /usr/bin/[ --oops --help
/usr/bin/[: missing `]'

> In conclusion: would you agree with a patch that converts automake and
> aclocal to the same cmdline-scanning behaviour of the majority of other
> GNU tools?  Such a patch would also have the advantage of *simplifying*
> the current code for command line parsing in automake and aclocal.

Not necessarily on the grounds of making things match other tools, but
definitely on the grounds of having simpler code that still complies
with GCS.

-- 
Eric Blake   [email-masked]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org