{"record":{"id":"d3f26a3307bddc0b","repo":"golang/go","slug":"empty-command","errorCode":null,"errorMessage":"empty command","messagePattern":"empty command","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cmd/internal/script/engine.go","lineNumber":392,"sourceCode":"\t\t\t}\n\n\t\t\t// Command prefix [cond] means only run this command if cond is satisfied.\n\t\t\tif strings.HasPrefix(arg, \"[\") && strings.HasSuffix(arg, \"]\") {\n\t\t\t\twant := true\n\t\t\t\targ = strings.TrimSpace(arg[1 : len(arg)-1])\n\t\t\t\tif strings.HasPrefix(arg, \"!\") {\n\t\t\t\t\twant = false\n\t\t\t\t\targ = strings.TrimSpace(arg[1:])\n\t\t\t\t}\n\t\t\t\tif arg == \"\" {\n\t\t\t\t\treturn errors.New(\"empty condition\")\n\t\t\t\t}\n\t\t\t\tcmd.conds = append(cmd.conds, condition{want: want, tag: arg})\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\tif arg == \"\" {\n\t\t\t\treturn errors.New(\"empty command\")\n\t\t\t}\n\t\t\tcmd.name = arg\n\t\t\treturn nil\n\t\t}\n\n\t\tcmd.rawArgs = append(cmd.rawArgs, rawArg)\n\t\treturn nil\n\t}\n\n\tfor i := 0; ; i++ {\n\t\tif !quoted && (i >= len(line) || strings.ContainsRune(argSepChars, rune(line[i]))) {\n\t\t\t// Found arg-separating space.\n\t\t\tif start >= 0 {\n\t\t\t\trawArg = append(rawArg, argFragment{s: line[start:i], quoted: false})\n\t\t\t\tstart = -1\n\t\t\t}\n\t\t\tif err := flushArg(); err != nil {\n\t\t\t\treturn nil, err","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/internal/script/engine.go#L374-L410","documentation":"Thrown by the script parser when the token that would become the command name is an empty unquoted string. After handling prefixes (!/?) and brackets, flushArg guards `arg == \"\"` for the command-name position. An empty unquoted command name is not meaningful, so it is rejected as a syntax error.","triggerScenarios":"Reaching this branch requires an unquoted empty token in the command position — a parser edge case rather than a normal user input, since ordinary whitespace collapses and would not produce a standalone empty token. It is primarily a defensive guard for unexpected parser state.","commonSituations":"Almost never hit by well-formed script input; typically surfaces only with crafted/malformed lines or future parser changes that accidentally yield an empty unquoted name token.","solutions":["Check the offending script line for stray tokens; ensure a real command name is present.","If you see this in practice, inspect the exact line bytes (hidden characters, tabs) since normal spaces should not produce this state.","Report as a parser bug if it reproduces with ordinary input."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Sanity-check that a command token is non-empty before relying on it.\nfunc nonEmptyCommand(name string) error {\n    if name == \"\" { return errors.New(\"empty command\") }\n    return nil\n}","typeGuard":"func isEmptyCommand(err error) bool {\n    return err != nil && err.Error() == \"empty command\"\n}","tryCatchPattern":"// Treat as a parser bug; inspect the exact line bytes if it reproduces.","preventionTips":["Inspect raw line bytes (tabs/hidden chars) if this appears.","Report to the script framework if reproducible with ordinary input."],"tags":["script","parser","test-framework","syntax-error"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}