#4325·rtk

`rtk ls` takes flag values for paths: `-I PATTERN` becomes a path operand, `-Ihello` is sent as `-Ieo`

Author: KuShCreated Sep 28, 2026Updated Sep 28, 2026
Labelsbugpriority:higharea:cli

What happens

rtk ls splits its arguments into flags and paths on a leading - alone, so it gets wrong any flag that takes a value.

  • Separate value: the value is treated as a path and moved after the flags. rtk ls -I '*.md' -R src/core runs ls -l -I -R *.md src/core. -R becomes the ignore pattern, *.md becomes a path operand, and the command exits 2. README.md is listed although -I '*.md' asked to hide it.
  • Attached value: the short-flag cluster is rebuilt by removing every l, a and h character, value included. -Ihello is sent as -Ieo. The same test also sets the long-listing detection, which looks for l/g/n/o anywhere in a short cluster.

Reproduce

bash
export LC_ALL=C
mkdir -p repro/src/core/sub && cd repro
touch src/core/a.rs src/core/README.md src/core/sub/b.rs

rtk ls -I '*.md' -R src/core; echo "rc=$?"
# src/core:
# total 4
# -rw-rw-r-- 1 user user    0 ... README.md
# -rw-rw-r-- 1 user user    0 ... a.rs
# drwxrwxr-x 2 user user 4096 ... sub
# ls: cannot access '*.md': No such file or directory
# rc=2

ls -l -I '*.md' -R src/core; echo "rc=$?"
# src/core:
# total 4
# -rw-rw-r-- 1 user user    0 ... a.rs
# drwxrwxr-x 2 user user 4096 ... sub
# (and src/core/sub)
# rc=0

The attached form (-Ihello → -Ieo) follows from the cluster rebuild in src/cmds/system/ls.rs (run: the flags/paths partition and the filter(|c| *c != 'l' && *c != 'a' && *c != 'h') loop).

Expected

Flag values stay attached to their flags, whether separate (-I PATTERN, --hide PATTERN, -w COLS, -T COLS, --block-size SIZE, --sort WORD, --time WORD, --format WORD, …) or attached (-Ihello, --ignore=*.md). A value is never taken for a path, and never edited by the cluster rebuild. Parsing through arg_tokenizer with ls's value table gives that.

Related

#3608 (-a handling) and #4302 (-t ordering) are other rtk ls flag problems, but neither covers flag values.