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
Open
fix(ls): fix empty output on non-English locales, hidden file leaking, and egg-info glob#8104fuu wants to merge 1 commit intortk-ai:developfrom
4fuu wants to merge 1 commit intortk-ai:developfrom
Conversation
…, 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>
e510489 to
4871f01
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problems
Three bugs in
rtk ls:1. Empty output on non-English locales
rtk lscallsls -lainternally and parses the output assuming the English date formatMar 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 theparts.len() < 9guard and silently skipping every entry — resulting in(empty)regardless of directory contents.2. Hidden files shown without
-artk lsalways runslswith-ainternally, but theshow_allflag incompact_lsonly controlled NOISE_DIRS filtering. Hidden entries (.dotnet/,.local/, etc.) were always included in the output even without-a.3.
*.egg-infoglob pattern never matchedNOISE_DIRScontains"*.egg-info", but the filter used strict equality (==). This glob pattern never matched real directories likemypackage.egg-info.Fixes
LC_ALL=Con thelssubprocess to force English date format and consistent 9-column output..incompact_lswhenshow_all=false.*now useends_withfor suffix matching instead of==.Tests
Three new test cases covering each scenario. All pass with
cargo test ls::.