Skip to content

fix(ls): fix empty output on non-English locales, hidden file leaking, and egg-info glob#810

Open
4fuu wants to merge 1 commit intortk-ai:developfrom
4fuu:fix/ls-locale-and-dotfiles
Open

fix(ls): fix empty output on non-English locales, hidden file leaking, and egg-info glob#810
4fuu wants to merge 1 commit intortk-ai:developfrom
4fuu:fix/ls-locale-and-dotfiles

Conversation

@4fuu
Copy link

@4fuu 4fuu commented Mar 25, 2026

Problems

Three bugs in rtk ls:

1. Empty output on non-English locales

rtk ls calls ls -la internally and parses the output assuming the English date format Mar 25 17:58 (3 tokens, 9 columns total), taking column index 8 as the filename.

On non-English locales (e.g. Chinese), the date is output as 3月25日 17:58 (2 tokens, 8 columns total), triggering the parts.len() < 9 guard and silently skipping every entry — resulting in (empty) regardless of directory contents.

2. Hidden files shown without -a

rtk ls always runs ls with -a internally, but the show_all flag in compact_ls only controlled NOISE_DIRS filtering. Hidden entries (.dotnet/, .local/, etc.) were always included in the output even without -a.

3. *.egg-info glob pattern never matched

NOISE_DIRS contains "*.egg-info", but the filter used strict equality (==). This glob pattern never matched real directories like mypackage.egg-info.

Fixes

  • Locale: set LC_ALL=C on the ls subprocess to force English date format and consistent 9-column output.
  • Hidden files: skip entries starting with . in compact_ls when show_all=false.
  • Glob matching: NOISE_DIRS patterns starting with * now use ends_with for suffix matching instead of ==.

Tests

Three new test cases covering each scenario. All pass with cargo test ls::.

@CLAassistant
Copy link

CLAassistant commented Mar 25, 2026

CLA assistant check
All committers have signed the CLA.

@4fuu 4fuu changed the base branch from master to develop March 25, 2026 10:22
…, and egg-info glob

- Set LC_ALL=C on the ls subprocess so date tokens are always
  "Mon DD HH:MM" (3 parts, 9 columns total). Non-English locales
  like Chinese output "3月25日 17:58" (2 parts, 8 columns), causing
  the filename parser to skip every entry and return "(empty)".

- Filter out dotfile entries when show_all=false. Previously rtk ls
  always ran ls -la internally but never suppressed hidden files,
  so .dotnet/, .local/ etc. appeared without -a.

- Support suffix-glob patterns in NOISE_DIRS (e.g. "*.egg-info").
  The existing == comparison never matched glob-style entries;
  patterns starting with "*" now use ends_with instead.

Add tests for all three cases.

Co-authored-by: Zhiyuan Zheng <zhizhen@microsoft.com>
@4fuu 4fuu force-pushed the fix/ls-locale-and-dotfiles branch from e510489 to 4871f01 Compare March 25, 2026 10:35
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.

2 participants