{"record":{"id":"78d02a04c1d83ec9","repo":"dotnet/runtime","slug":"option-s-invalid-form","errorCode":null,"errorMessage":"Option %s: invalid form\n","messagePattern":"Option (.+?): invalid form\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/coreclr/hosts/corerun/corerun.cpp","lineNumber":769,"sourceCode":"            i++; // Move to next argument.\n\n            config.entry_assembly_argc = argc - i;\n            config.entry_assembly_argv = (const char_t**)::malloc(config.entry_assembly_argc * sizeof(const char_t*));\n            assert(config.entry_assembly_argv != nullptr);\n            for (int c = 0; c < config.entry_assembly_argc; ++c)\n            {\n                config.entry_assembly_argv[c] = pal::strdup(argv[i + c]);\n            }\n\n            // Successfully parsed arguments.\n            return true;\n        }\n\n        const char_t* arg = argv[i];\n        size_t arg_len = pal::strlen(arg);\n        if (arg_len == 1)\n        {\n            pal::fprintf(stderr, W(\"Option %s: invalid form\\n\"), arg);\n            break; // Invalid option\n        }\n\n        const char_t* option = arg + 1;\n        if (option[0] == W('-')) // Handle double '--'\n            option++;\n\n        // Path to core_root\n        if (pal::strcmp(option, W(\"c\")) == 0 || (pal::strcmp(option, W(\"clr-path\")) == 0))\n        {\n            i++;\n            if (i < argc)\n            {\n                config.clr_path = argv[i];\n            }\n            else\n            {\n                pal::fprintf(stderr, W(\"Option %s: missing path\\n\"), arg);","sourceCodeStart":751,"sourceCodeEnd":787,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/coreclr/hosts/corerun/corerun.cpp#L751-L787","documentation":"Printed at src/coreclr/hosts/corerun/corerun.cpp:769 when an option token consists of only a single dash/flag character (arg length is 1). corerun cannot tell which option was intended, so it bails out of argument parsing.","triggerScenarios":"Triggered when argv[i] is exactly \"-\" (one character). parse_args sets is_option true because the first char is a dash, then finds arg_len==1 and prints this message before breaking out of the loop.","commonSituations":"A typo such as `corerun - assembly.dll` where the user meant `-d`, or shell pipelines that inadvertently pass a lone dash to corerun.","solutions":["Inspect the corerun command line and remove or correct the lone `-`.","Use `corerun --help` to list valid options.","Quote arguments in shell scripts to avoid a stray dash being passed."],"exampleFix":"// before\ncorerun - HelloWorld.dll\n// after\ncorerun -d HelloWorld.dll","handlingStrategy":"validation","validationCode":"// Before calling corerun, scrub argv\nbool clean_args(int argc, char** argv) {\n    for (int i=1;i<argc;i++) {\n        if (argv[i][0]=='-' && argv[i][1]=='\\0') return false; // lone dash\n    }\n    return true;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Inspect corerun command lines for stray single dashes.","Quote arguments in shell scripts.","Run `corerun --help` to see valid option syntax."],"tags":["coreclr","corerun","cli","argument-parsing"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}