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
Copy Markdown

@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
Copy Markdown

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
@4fuu 4fuu force-pushed the fix/ls-locale-and-dotfiles branch from e510489 to 4871f01 Compare March 25, 2026 10:35
@aeppling
Copy link
Copy Markdown
Contributor

Hey

We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes src/ from a flat layout into subfolders.

No logic changes — only file moves and import path updates.

What you need to do

Rebase your branch on develop when receiving this comment:

git fetch origin && git rebase origin/develop

Git detects renames automatically. If you get import conflicts, update the paths:

use crate::git;        // now: use crate::cmds::git::git;
use crate::tracking;   // now: use crate::core::tracking;
use crate::config;     // now: use crate::core::config;
use crate::init;       // now: use crate::hooks::init;
use crate::gain;       // now: use crate::analytics::gain;

Need help rebasing? Tag @aeppling

…, 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 4871f01 to c17a609 Compare March 27, 2026 02:10
@4fuu
Copy link
Copy Markdown
Author

4fuu commented Mar 27, 2026

Done, rebased on upstream/develop.

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.

4 participants