rtk find: `--max 0` prints an empty first line before `+N more`
What happens
With --max 0 (or -m 0) and at least one match, rtk find prints an empty first line before the +N more line. The output is \n+120 more\n instead of a single line. It happens with both native (-name only) and find-backed queries (for example with -size), and with the legacy rtk find '<glob>' syntax.
Reproduce
mkdir findmax0 && cd findmax0
for i in $(seq -w 1 120); do : > "f$i.txt"; done
rtk find . -name '*.txt' --max 0 </dev/null | od -c; echo "exit ${PIPESTATUS[0]}"Observed (develop at 7efbaef46):
0000000 \n + 1 2 0 m o r e \n
0000013
exit 0Same bytes from rtk find . -name '*.txt' -m 0, rtk find . -name '*.txt' -size -1k --max 0 and rtk find '*.txt' --max 0.
GNU find for the same query lists the 120 files (--max is rtk's own flag, it has no find counterpart):
$ find . -name '*.txt' | wc -l
120Expected
No leading empty line: +120 more on the first line of the output.
Code location
src/cmds/system/find_cmd.rs, build_capped_listing: when max_results is 0 the joined listing is empty, and the function then appends "\n+{} more", so the text starts with \n. render passes that text (with only trailing newlines trimmed) as the baseline to core::runner::emit_guarded. The grouped body (120F 1D: header, blank line, +120 more) is longer, so core::guard::never_worse prints the baseline, leading newline included.
Source: rtk-ai/rtk