fix(ls): force LC_TIME=C for locale-independent date parsing#1689
fix(ls): force LC_TIME=C for locale-independent date parsing#1689lakewaban wants to merge 1 commit intortk-ai:masterfrom
Conversation
signed,please recheck it |
The LS_DATE_RE regex expects English month names (Jan, Feb, etc.), but ls -la output uses numeric months (5, 6, etc.) when the user's locale sets LC_TIME to a non-English language. This causes parse_ls_line() to fail on every line, making rtk ls always return '(empty)' on such systems (e.g. Chinese locale). Fix by setting LC_TIME=C before executing ls, ensuring the date format is always 'May 3 12:23' regardless of system locale. Fixes #(issue number if known)
937b01b to
52985bf
Compare
|
Hi, thanks for your PR. This issue is more general than that. The #1338 have just been merged which should fix your problem, if not would you be willing to extend your PR and its associated tests to address these cases as well? The following issues appear to be related: |
The LS_DATE_RE regex expects English month names (Jan, Feb, etc.), but ls -la output uses numeric months (5, 6, etc.) when the user's locale sets LC_TIME to a non-English language.
This causes parse_ls_line() to fail on every line, making rtk ls always return '(empty)' on such systems (e.g. Chinese locale).
Fix by setting LC_TIME=C before executing ls, ensuring the date format is always 'May 3 12:23' regardless of system locale.
Fixes #(issue number if known)
Summary
LC_TIME=Cin thelscommand environment so thatls -laoutput always uses English month names, matching theLS_DATE_REregex inparse_ls_line()rtk lsreturning(empty)on systems with non-English locales (e.g.zh_CN.UTF-8)Test plan
cargo fmt --all && cargo clippy --all-targets && cargo testLC_TIME=zh_CN.UTF-8 rtk lsshould now show files instead of(empty)rtk lswith default English locale still works correctlyrtk lsoutput inspected on both English and Chinese locale