fd icon indicating copy to clipboard operation
fd copied to clipboard

[BUG] `--format` rejects templates starting with `-` and gives a misleading error suggestion

Open Juemuren opened this issue 2 months ago • 0 comments

Checks

  • [x] I have read the troubleshooting section and still think this is a bug.

Describe the bug you encountered:

When using --format <fmt>, a format string starting with - is rejected:

> fd --format "- {/.}"
error: unexpected argument '- ' found

  tip: to pass '- ' as a value, use '-- - '

Usage: fd.exe [OPTIONS] [pattern] [path]...

For more information, try '--help'.

But --format="- {/.}" can work.

The help text presents the option as:

--format <fmt>
    Print results according to template

This suggests that a template can be passed as the next argument. It does not mention a restriction on templates starting with -. Generating a Markdown list is a straightforward use of this option, but following the documented syntax fails, and the error suggestion does not explain how to fix it.

The suggestion to use -- is confusing here because the intended value belongs to --format, rather than being a positional argument.

Describe what you expected to happen:

--format "- {/.}" should accept the string as the format value, consistent with the documented --format <fmt> syntax, and print:

- a
- b
- ...

If requiring = for these templates is intentional, the help text should explain this restriction, and the error should suggest --format="- {/.}" instead of directing the user toward --.

What version of fd are you using?

fd 10.5.0

Which operating system / distribution are you on?

Windows WIN32_NT 10.0.26200.9168 x86_64

Juemuren avatar Sep 07 '26 22:09 Juemuren