glibc getopt() optional argument This is the problem: foo -abcRdefg If 'R' is an element that specifies an optional argument, then the "defg" string is taken as its argument, it is pointed by optarg, but this is not what the user wants, in fact, he expects that the "defg" characters are parsed as other option elements. In other words the user expects this: foo -abc -R -defg The solution is to assign arguments to 'R' only in these cases: foo -abcR option_to_R bar -abc -R option_to_R The patch is here: http://freaknet.org/alpt/src/patches/getopt-opt-arg/getopt-option-arg.patch This text can be found here: http://freaknet.org/alpt/src/patches/getopt-opt-arg/readme AlpT (@freaknet.org)