{"record":{"id":"732171fc4d042dfa","repo":"NationalSecurityAgency/ghidra","slug":"s-option-w-s-is-ambiguous-n","errorCode":null,"errorMessage":"%s: option `-W %s' is ambiguous\\n","messagePattern":"(.+?): option `-W (.+?)' is ambiguous\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"GPL/DemanglerGnu/src/demangler_gnu_v2_41/c/getopt.c","lineNumber":873,"sourceCode":"\t\t  pfound = p;\n\t\t  indfound = option_index;\n\t\t  exact = 1;\n\t\t  break;\n\t\t}\n\t      else if (pfound == NULL)\n\t\t{\n\t\t  /* First nonexact match found.  */\n\t\t  pfound = p;\n\t\t  indfound = option_index;\n\t\t}\n\t      else\n\t\t/* Second or later nonexact match found.  */\n\t\tambig = 1;\n\t    }\n\tif (ambig && !exact)\n\t  {\n\t    if (opterr)\n\t      fprintf (stderr, _(\"%s: option `-W %s' is ambiguous\\n\"),\n\t\t       argv[0], argv[optind]);\n\t    nextchar += strlen (nextchar);\n\t    optind++;\n\t    return '?';\n\t  }\n\tif (pfound != NULL)\n\t  {\n\t    option_index = indfound;\n\t    if (*nameend)\n\t      {\n\t\t/* Don't test has_arg with >, because some C compilers don't\n\t\t   allow it to be used on enums.  */\n\t\tif (pfound->has_arg)\n\t\t  optarg = nameend + 1;\n\t\telse\n\t\t  {\n\t\t    if (opterr)\n\t\t      fprintf (stderr, _(\"\\","sourceCodeStart":855,"sourceCodeEnd":891,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/GPL/DemanglerGnu/src/demangler_gnu_v2_41/c/getopt.c#L855-L891","documentation":"GNU getopt_long `-W` ambiguity diagnostic. The POSIX `-W foo` shorthand for `--foo` matched more than one long option (a prefix match) with no exact match, so getopt cannot decide which one. It consumes the rest of the token, advances optind, and returns '?'.","triggerScenarios":"getopt_long supports `-W` via an optstring containing `W;`. The user passes `-W <prefix>` where <prefix> is a non-unique prefix of two or more long options (e.g. long opts `--verbose` and `--version` invoked as `-W ver`).","commonSituations":"Long-option names share a common prefix; abbreviation is relied upon and later becomes ambiguous after a new option is added.","solutions":["Type the full long-option name after `-W` instead of an ambiguous abbreviation.","Invoke via the `--name` form directly to avoid the `-W` shorthand.","Rename long options so prefixes are unambiguous, or add an exact-match-only option.","Disable `-W` processing by removing `W;` from optstring if the shorthand is not needed."],"exampleFix":"// before: long options {\"verbose\"},{\"version\"}; invocation  prog -W ver\n//   -> option `-W ver' is ambiguous\n\n// after: use the full name or the -- form\n//   prog -W verbose\n//   prog --verbose","handlingStrategy":"validation","validationCode":"// reject ambiguous -W prefixes before getopt, or require full long names\nif (strncmp(arg, \"-W\", 2) == 0 && isAmbiguousPrefix(arg+2, long_opts)) {\n  fprintf(stderr, \"use the full --name\\n\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Discourage -W abbreviation; prefer --longname.","Design long-option names with distinct first letters.","Remove W; from optstring if -W shorthand is unneeded."],"tags":["cli","getopt","getopt-long","argument-parsing","c"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}