[Bug 1448] Report wrong command-line options

bugzilla-daemon at mindrot.org
Fri, 10 May 2013 04:27:32 -0000

Darren Tucker <dtucker at zip.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dtucker at zip.com.au

--- Comment #4 from Darren Tucker <dtucker at zip.com.au> ---
whatever it is, it doesn't seem to be gnu-getopt specific.  or if it
is, it's not enabled with the default set of defines.

#include <stdio.h>
#include <unistd.h>

int main(int argc, char **argv)
{
    int ch;
    while ((ch = getopt(argc, argv, "abc:")) != -1) {
        printf("opt %c optarg %s\n", ch, optarg ? optarg :
"(null)");
    }
}

gives me:
$ ./a.out --foo
./a.out: invalid option -- '-'
opt ? optarg (null)
./a.out: invalid option -- 'f'
opt ? optarg (null)
./a.out: invalid option -- 'o'
opt ? optarg (null)
./a.out: invalid option -- 'o'
opt ? optarg (null)

whatever it is, I think it's in our compat library:
$ nm scp | grep -i getop
08051710 T BSDgetopt