go-delve/delve · error

unrecognized option %q

Error message

unrecognized option %q

What it means

`display -save <path>` parses its arguments as flags (`-t` for truncate, `-off` to disable) plus one optional path. An argument starting with `-` that is not a known flag — or a second path after one was already given — is rejected as an unrecognized option.

Source

Thrown at pkg/terminal/command.go:3499

}

func transcript(t *Term, ctx callContext, args string) error {
	argv := strings.SplitN(args, " ", -1)
	truncate := false
	fileOnly := false
	disable := false
	path := ""
	for _, arg := range argv {
		switch arg {
		case "-x":
			fileOnly = true
		case "-t":
			truncate = true
		case "-off":
			disable = true
		default:
			if path != "" || strings.HasPrefix(arg, "-") {
				return fmt.Errorf("unrecognized option %q", arg)
			} else {
				path = arg
			}
		}
	}

	if disable {
		if path != "" {
			return errors.New("-o option specified with an output path")
		}
		return t.stdout.CloseTranscript()
	}

	if path == "" {
		return errors.New("no output path specified")
	}

	flags := os.O_APPEND | os.O_WRONLY | os.O_CREATE

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Use only `-t` (truncate) or `-off` (disable) flags before the path
  2. Provide exactly one path that does not begin with `-`
  3. Check flag spelling/case (single dash, short form)

Example fix

// before
display -save --truncate /tmp/displays.txt
// after
display -save -t /tmp/displays.txt
Defensive patterns

Strategy: try-catch

Try / catch

for _, a := range args {
    if strings.HasPrefix(a, "-") && a != "-t" && a != "-off" {
        return fmt.Errorf("unsupported flag %q for display -save", a)
    }
}

Prevention

When it happens

Trigger: Running `display -save --foo path`, `display -save -x`, or giving two paths like `display -save a.txt b.txt` (second non-flag arg when path already set).

Common situations: Using GNU-style long flags (`--truncate`) that Delve doesn't support; typo'd flags; passing extra filename arguments. Note also that a path starting with `-` will be misread as a flag.

Related errors


AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/7cf7be47001fe9f7. Report an issue: GitHub.