{"record":{"id":"83f1b9f8cc37de7b","repo":"go-delve/delve","slug":"illegal-commandline-s","errorCode":null,"errorMessage":"illegal commandline '%s'","messagePattern":"illegal commandline '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/terminal/command.go","lineNumber":1283,"sourceCode":"\t\tfmt.Fprintf(t.stdout, \"Discarded %s at %s: %v\\n\", formatBreakpointName(discarded[i].Breakpoint, false), t.formatBreakpointLocation(discarded[i].Breakpoint), discarded[i].Reason)\n\t}\n\treturn nil\n}\n\nfunc parseNewArgv(args string) (resetArgs bool, newArgv []string, newRedirects [3]string, err error) {\n\tif args == \"\" {\n\t\treturn false, nil, [3]string{}, nil\n\t}\n\tv, err := argv.Argv(args,\n\t\tfunc(s string) (string, error) {\n\t\t\treturn \"\", fmt.Errorf(\"Backtick not supported in '%s'\", s)\n\t\t},\n\t\tnil)\n\tif err != nil {\n\t\treturn false, nil, [3]string{}, err\n\t}\n\tif len(v) != 1 {\n\t\treturn false, nil, [3]string{}, fmt.Errorf(\"illegal commandline '%s'\", args)\n\t}\n\tw := v[0]\n\tif len(w) == 0 {\n\t\treturn false, nil, [3]string{}, nil\n\t}\n\tif w[0] == \"-noargs\" {\n\t\tif len(w) > 1 {\n\t\t\treturn false, nil, [3]string{}, errors.New(\"too many arguments to restart\")\n\t\t}\n\t\treturn true, nil, [3]string{}, nil\n\t}\n\tredirs := [3]string{}\n\tfor len(w) > 0 {\n\t\tvar found bool\n\t\tvar err error\n\t\tw, found, err = parseOneRedirect(w, &redirs)\n\t\tif err != nil {\n\t\t\treturn false, nil, [3]string{}, err","sourceCodeStart":1265,"sourceCodeEnd":1301,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/terminal/command.go#L1265-L1301","documentation":"parseNewArgv parses the optional new program arguments given to the 'restart' command in the Delve terminal. The string is tokenized by argv.Argv into a slice of command lines (slices of words); a legal restart argument is exactly one command line. When the tokenizer produces zero or more than one command line, Delve cannot map it onto a single new argv, so it rejects the whole input with 'illegal commandline'.","triggerScenarios":"Running `restart <args>` where args contains unbalanced quotes, backtick-substitution attempts, or tokenizes into multiple command lines (len(v) != 1), e.g. stray semicolons/pipes or an empty-but-nonempty-looking argument string. Called from restartRecorded, restartLive and directly exercised by TestParseNewArgv.","commonSituations":"Users paste a shell command with pipes/redirects shell-style into restart; quoting from another shell is copied verbatim and breaks argv parsing; an editor/IDE plugin passes a malformed restart args string.","solutions":["Re-run restart with a single, simply-quoted command line (no pipes, semicolons, or backticks), e.g. `restart arg1 \"arg two\"`.","Remove any backtick substitution; it is explicitly unsupported here.","Check quoting: ensure quotes are balanced and there is exactly one command (one argv vector) in the argument string.","If you need shell features (pipes, redirection chains), launch the program outside Delve and attach, or precompute the args."],"exampleFix":"// before\nrestart foo | grep bar\n// error: illegal commandline 'foo | grep bar'\n\n// after\nrestart foo\n// run grep on the output outside the debugger","handlingStrategy":"validation","validationCode":"// Validate a restart args string before passing it to the restart command\nfunc validRestartArgs(args string) bool {\n    if args == \"\" {\n        return true\n    }\n    if strings.ContainsAny(args, \"`;|\") {\n        return false // backticks unsupported; pipes/semicolons yield multiple argv\n    }\n    // crude balance check for quotes\n    return strings.Count(args, \"\\\"\")%2 == 0 && strings.Count(args, \"'\")%2 == 0\n}","typeGuard":null,"tryCatchPattern":"// terminal command errors surface as the returned error\nif err := cmd.Execute(\"restart \"+args); err != nil {\n    if strings.Contains(err.Error(), \"illegal commandline\") {\n        fmt.Fprintf(os.Stderr, \"invalid restart args %q: use a single quoted command line\\n\", args)\n    }\n}","preventionTips":["Pass restart args as a single command line, no pipes/semicolons/backticks.","Quote arguments containing spaces individually.","Never paste raw shell pipelines into restart.","Add unit tests (like TestParseNewArgv) for any programmatically built restart strings."],"tags":["terminal","argument-parsing","cli","delve"],"backgroundTag":"illegal-commandline","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}