On Mon, Apr 27, 2015 at 12:18:16PM -0400, Rich Felker wrote: > I read the gnulib code but I don't see why it expects a match. From > the glibc code it looks to me like the ambig_list should have length 2 > and produce an error. I don't see any reasonable way getopt_long could > choose between the two choices for the user without violating a > principle of least surprise. Do you get what's going on? > > Rich glibc only adds to ambig_list if the following condition is met: if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val) so I guess if all the matching option structs are the same, you're allowed to pick any matching option for longindex (unless you're in getopt_long_only).