#4320·rtk

rtk diff <file> with one operand echoes stdin and exits 0 where diff exits 2

Author: KuShCreated Sep 28, 2026Updated Sep 28, 2026
Labelsbugarea:clipriority:medium

What happens

With exactly one file operand, rtk diff <file> ignores the file, echoes stdin back as if it were a unified diff to condense, and exits 0. diff with one operand is a usage error (exit 2).

The hook rewrites a bare diff <file> to rtk diff <file> (rtk rewrite 'diff o.txt' → rtk diff o.txt), so a command meant to fail on bad usage succeeds instead.

Reproduce

bash
export LC_ALL=C
printf 'a\n' > o.txt

printf 'zzz\n' | rtk diff o.txt;      echo "rc=$?"   # prints zzz, rc=0
printf 'zzz\n' | rtk diff nope.txt;   echo "rc=$?"   # missing file: prints zzz, rc=0
rtk diff o.txt </dev/null;            echo "rc=$?"   # rc=0

diff o.txt </dev/null;                echo "rc=$?"   # diff: missing operand after 'o.txt', rc=2

A missing file is not reported either: the operand is never opened.

Expected

Match diff's exit contract for the one-operand form. Report the usage error with exit 2, or hand the invocation to diff so it reports it. A diff <file> && next step then stops where diff would stop.

Related

  • #3780 covers the other one-operand form, a bare rtk diff - (exit 0 where diff gives a usage error), and - as an operand next to a file.
  • #3781 fixes the two-operand - forms only and leaves this path unchanged.