junegunn/fzf · error
unexpected value for %s: %s
Error message
unexpected value for %s: %s
What it means
A standalone (no-value) option was given a value. During parsing, certain options are recognized as flags with no argument; if the parser then finds a leftover attached value, it raises 'unexpected value for <arg>: <value>'.
Source
Thrown at src/options.go:3503
} else if match, value := optString(arg, "-d"); match {
opts.Delimiter = delimiterRegexp(value)
} else if match, value := optString(arg, "-n"); match {
if opts.Nth, err = splitNth(value); err != nil {
return err
}
} else if match, _ := optString(arg, "-s"); match {
opts.Sort = 1 // Don't care
} else if match, value := optString(arg, "-m"); match {
if opts.Multi, err = atoi(value); err != nil {
return err
}
} else {
return errors.New("unknown option: " + arg)
}
}
if val != nil {
return errors.New("unexpected value for " + arg + ": " + *val)
}
}
*index += len(allArgs)
if opts.HeaderLines < 0 {
return errors.New("header lines must be a non-negative integer")
}
if opts.HscrollOff < 0 {
return errors.New("hscroll offset must be a non-negative integer")
}
if opts.ScrollOff < 0 {
return errors.New("scroll offset must be a non-negative integer")
}
if opts.Tabstop < 1 {
return errors.New("tab stop must be a positive integer")View on GitHub (pinned to bd4efa277b)
Solutions
- Remove the value: use the flag alone (e.g. -s not -s 1)
- For boolean-style long options, drop the '=...' suffix
- Check fzf --help to see which options take a value
Example fix
# before fzf -s 1 # after fzf -s
Defensive patterns
Strategy: validation
Validate before calling
// Shell: strip '=...' from valueless flags
valueless='-s --sync --no-sort --reverse +s +i +x'
args=()
for a in "$@"; do
k="${a%%=*}"
[[ $valueless == *"$k"* && "$a" == *=* ]] && a="$k"
args+=("$a")
done
exec fzf "${args[@]}" Prevention
- Learn which fzf flags are valueless (-s, +s, --sync) and never attach values
- Keep a list of boolean flags in your wrapper and normalize '=true' suffixes
- Read errors as 'unexpected value for X' meaning X takes no argument
When it happens
Trigger: Writing something like -s 1 or --sync=true where the option takes no value: after the option is consumed, the leftover value (val != nil) triggers errors.New("unexpected value for " + arg + ": " + *val) at options.go:3503. Also triggered by '--flag=value' syntax for boolean-style flags in this branch.
Common situations: Applying '=value' syntax to flags that accept no value; copy-pasting option lines from other tools; assuming all long options take arguments.
Related errors
- unknown option: %s
- unsupported style preset: %s
- at least one of 'file' or 'dir' should be specified
- unable to put non-printable character
- unknown action: ${spec}
AI-assisted analysis of junegunn/fzf@bd4efa277b (2026-08-15).
Data as JSON: /api/errors/edc6022fa038650a.
Report an issue: GitHub.