rtk icon indicating copy to clipboard operation
rtk copied to clipboard

rtk ls with multiple directory arguments omits per-directory headers

Open Osatona opened this issue 4 months ago โ€ข 3 comments

Summary

rtk ls dirA dirB (and any N-directory invocation) flattens every directory's entries into one list with no per-directory attribution, unlike native ls, which prints a path: header before each directory's listing. A file can appear to belong to the first directory listed when it actually came from another.

This is distinct from #2271 / PR #2272, which fixes header loss for ls -R (single-directory recursive). The case here is triggered by passing multiple directory operands to non-recursive ls, so it isn't covered by that fix.

Repro

$ mkdir -p dirA dirB && echo a1 > dirA/file_a.txt && echo b1 > dirB/file_b.txt

$ ls dirA dirB
dirA:
file_a.txt

dirB:
file_b.txt

$ rtk ls dirA dirB
file_a.txt  3B
file_b.txt  3B

Expected: output preserves the per-directory path: headers (or equivalent attribution) that native ls prints whenever more than one directory operand is given.

Actual: entries from all directories are merged into a single flat list with no indication of which directory each file came from.

Impact

Deterministic whenever more than one directory is passed and at least one is non-empty. Misleads any check that depends on directory membership (e.g. "did file X land in stage A or stage B of a pipeline") into attributing a file to the wrong directory, since the merged list reads as if everything came from the first path.

Environment

rtk 0.43.0, Windows (Git Bash).

Workaround

rtk proxy ls dirA dirB (unfiltered passthrough) or one directory at a time via rtk proxy ls <dir>.

Osatona avatar Jul 07 '26 01:07 Osatona

wshm ยท Automated triage by AI

๐Ÿ” Automated Triage

๐Ÿ› Category bug
๐ŸŸก Priority medium
๐ŸŽฏ Confidence 85%

Summary

rtk ls with multiple directory arguments merges all entries into one flat list without per-directory 'path:' headers like native ls; add per-directory attribution for multi-operand ls calls.

This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

๐Ÿ“ Relevant files
  • src/ls_cmd.rs

Triaged automatically by wshm ยท This is an automated analysis, not a human review.

pszymkowiak avatar Jul 07 '26 01:07 pszymkowiak

reproduced on macos

NickSpag avatar Jul 16 '26 12:07 NickSpag

Confirmed with long listings on Ubuntu 26.04.1 LTS x86-64, RTK 1.2.1 full release. Short multi-directory output preserved both headings in this fixture. Long output lost both, so the listing no longer identifies the directory containing y.

# In an empty directory
export LC_ALL=C
mkdir -p a/d b
printf 'content\n' > a/x
touch b/y
chmod 755 a/d
chmod 644 a/x b/y
ls -l a b | sed -n '/^[ab]:$/p'
rtk ls -l a b | sed -n '/^[ab]:$/p'

Expected and observed from native:

a:
b:

The RTK heading check produced zero lines. Before the heading filter, the RTK listing contained 755 d/, 644 x 8B, and 644 y 0B, followed by its filtering and recall notices.

SNComrade avatar Nov 26 '26 11:11 SNComrade