bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

getopt returns '?' in stead of ':' on missing argument


From: Rasmus Storjohann
Subject: getopt returns '?' in stead of ':' on missing argument
Date: Wed, 13 Dec 2000 04:31:02 -0800 (PST)

I haven't checked the bugs database for this one since I do not have the
time to commit to regular contributions, and therefore did not want to get
a login to it.

getopt returns '?' on all types of errors except if an option that is
supposed to take an argument is not given an argument. In this case ':' is
supposed to be returned. When I check this, getopt returns '?' also in
this case.

I'm running glibc version glibc-2.1.3-15. Running this code:

/////////////////////////////////

#include <unistd.h>

int main (int argc, char** argv)
{
        printf("%c\n",getopt(argc,argv,"c:"));
}

////////////////////////////////

with the command line option "-c" gives this output:

getopt 1021$ ./a.out -c
./a.out: option requires an argument -- c
?
getopt 1022$ 

rather than this, which is what the source code states should be the
output in this situation (made by editing the ebove):

getopt 1021$ ./a.out -c
./a.out: option requires an argument -- c
:
getopt 1022$



Rasmus Storjohann




reply via email to

[Prev in Thread] Current Thread [Next in Thread]