`rtk ls` takes flag values for paths: `-I PATTERN` becomes a path operand, `-Ihello` is sent as `-Ieo`
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/corerunsls -l -I -R *.md src/core.-Rbecomes the ignore pattern,*.mdbecomes a path operand, and the command exits 2.README.mdis listed although-I '*.md'asked to hide it. - Attached value: the short-flag cluster is rebuilt by removing every
l,aandhcharacter, value included.-Ihellois sent as-Ieo. The same test also sets the long-listing detection, which looks forl/g/n/oanywhere in a short cluster.
Reproduce
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=0The 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.
Source: rtk-ai/rtk