NationalSecurityAgency/ghidra · warning
%s: option `%s' requires an argument
Error message
%s: option `%s' requires an argument
What it means
GNU getopt long-option path: the matched option has has_arg == 1 (required_argument) but no argument is available (optind >= argc, i.e. the option was last on the command line with no following token and no attached =value). With opterr set, getopt prints this and returns optstring[0]==':' ? ':' : '?'. It is a missing-required-argument usage error.
Source
Thrown at GPL/DemanglerGnu/src/demangler_gnu_v2_24/c/getopt.c:734
fprintf (stderr,
_("%s: option `%c%s' doesn't allow an argument\n"),
argv[0], argv[optind - 1][0], pfound->name);
nextchar += strlen (nextchar);
optopt = pfound->val;
return '?';
}
}
}
else if (pfound->has_arg == 1)
{
if (optind < argc)
optarg = argv[optind++];
else
{
if (opterr)
fprintf (stderr,
_("%s: option `%s' requires an argument\n"),
argv[0], argv[optind - 1]);
nextchar += strlen (nextchar);
optopt = pfound->val;
return optstring[0] == ':' ? ':' : '?';
}
}
nextchar += strlen (nextchar);
if (longind != NULL)
*longind = option_index;
if (pfound->flag)
{
*(pfound->flag) = pfound->val;
return 0;
}
return pfound->val;
}
View on GitHub (pinned to d5f144c24d)
Solutions
- Provide the required argument: --style=gnu or --style gnu.
- Check --help to confirm which options require arguments and their expected values.
- Quote/escape the argument so the shell passes it as one token that getopt can consume.
- Review the script's conditional flag-building to ensure value and flag are appended together.
Example fix
# before $ tool --style ... option `--style' requires an argument # after $ tool --style gnu # or --style=gnu
Defensive patterns
Strategy: validation
Validate before calling
// Ensure required-argument options always receive a value
if (optionRequiresArg(name) && value == null) {
throw new IllegalArgumentException("Option " + name + " requires an argument");
} Type guard
boolean isCompleteInvocation(String name, String value, Set<String> requiredArgFlags) {
return !requiredArgFlags.contains(name) || value != null;
} Try / catch
int rc = run_child({"tool", "--" + name});
if (rc != 0 && stderr_contains("requires an argument")) {
// prompt for or supply the missing value, then re-run
} Prevention
- Consult --help to learn which options require arguments.
- When conditionally appending a flag, always append its value in the same branch.
- Quote the argument so the shell delivers it as one token for getopt to consume.
- Validate assembled argument lists against the option spec before invoking the tool.
When it happens
Trigger: Specifying a long option that requires an argument but providing none - e.g. '--style' as the last token with no following value and no '=value'. getopt looks for the next argv element, finds none, and reports the requirement.
Common situations: Forgetting the value for an option that needs one (-o/--output with no filename); the value being swallowed by shell quoting/word-splitting so getopt sees the option as last; a script conditionally appending the flag but not its value; trailing-option positioned where the value is parsed as another flag.
Related errors
- %s: option `%s' is ambiguous
- %s: option `--%s' doesn't allow an argument
- %s: option `%c%s' doesn't allow an argument
- %s: unknown demangling style `%s'
- %s: unrecognized option `--%s'
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/e340f622ab47b0ff.
Report an issue: GitHub.