Skip to content

fix/ls 1 flag 2058#2061

Open
pen-pal wants to merge 3 commits into
rtk-ai:developfrom
pen-pal:fix/ls-1-flag-2058
Open

fix/ls 1 flag 2058#2061
pen-pal wants to merge 3 commits into
rtk-ai:developfrom
pen-pal:fix/ls-1-flag-2058

Conversation

@pen-pal
Copy link
Copy Markdown

@pen-pal pen-pal commented May 24, 2026

Summary

  • Fixes rtk ls -1 path/ Always Return (empty) #2058:
  • rtk ls -1 path/ returned (empty) on BSD /bin/ls because ls -la -1 honors the last format flag, producing filename-only output the parser can't decode.
  • Strips display-format flags (-1, -C, -m, -x) alongside the already-enforced -l/-a/-h before invoking ls. RTK's compact output is one-per-line anyway, so users get the layout they asked for.
  • Split into 3 commits: refactor (extract build_ls_args), fix (+ primary regression test), test (14 more edge cases covering placement, sibling flags, compound splits, mixed groups, repetition).

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test — 1943 pass, 0 fail, clippy clean
  • Manual testing: PATH=/bin:/usr/bin rtk ls -1 /tmp/testdir/ returns compact output (a.txt 0B ...), not (empty) or raw filenames

pen-pal added 3 commits May 24, 2026 05:42
Pure refactor with no behavior change — pulls the flag-merging and path
handling into a standalone function so it can be unit-tested without
spawning an `ls` subprocess. The forced `-la` enforcement and `-l`/`-a`/
`-h` stripping move with it. Existing tests pass unchanged.

Prepares ground for rtk-ai#2058 fix where the strip list needs to grow to
cover display-format flags that override `-l`.

Signed-off-by: penpal <unameme@proton.me>
`rtk ls -1 path/` returned `(empty)` (or raw filenames on the fallback
path) because BSD `/bin/ls` honors the last format flag — `ls -la -1`
produces filename-only output the parser can't decode.

Strip `-1`, `-C`, `-m`, `-x` from short-flag combinations alongside the
already-enforced `-l`/`-a`/`-h`. RTK's compact output is already
one-per-line, so users get the layout they asked for. Compound flags
like `-1r` preserve `-r`.

Includes the rtk-ai#2058 regression test on the primary failure case.
Broader coverage (placement variations, sibling flags, compound splits,
mixed groups, repetition) follows in a separate test commit.

Signed-off-by: penpal <unameme@proton.me>
Adds 14 more unit tests around the fix from the previous commit so
future refactors can't silently regress it:

- placement variations: `-1` bare, before path, after path, no path
- sibling format flags: `-C`, `-m`, `-x`
- harmless flag preservation: `-r`, `-t`, `-S`, `--reverse`
- compound splits: `-1r` → `-r`, `-lar` → `-r`
- multiple format flags combined: `-1C`, `-1Cmx`
- format flags mixed with -la: `-la1`, `-1la`, `-l1a`
- compound with several kept chars: `-1rt`, `-r1t`
- repeated format flag across args: `[-1 -1 -r path/]`
- end-to-end safety net: BSD filename-only output through compact_ls

The repetition test in particular guards against someone refactoring
the per-arg char filter into a global one-shot strip, which would pass
the simple cases but lose state across args.

Signed-off-by: penpal <unameme@proton.me>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 24, 2026

CLA assistant check
All committers have signed the CLA.

@pen-pal pen-pal changed the title Fix/ls 1 flag 2058 fix/ls 1 flag 2058 May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk ls -1 path/ Always Return (empty)

2 participants