Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/cmds/system/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ pub fn run(args: &[String], verbose: u8) -> Result<i32> {
.collect();

let mut cmd = resolved_command("ls");
// Force C locale so month names match LS_DATE_RE, which is English-only.
// Without this, non-English locales (e.g. LC_TIME=pt_BR.UTF-8 → "abr"/"mar")
// cause every line to fail the regex, and compact_ls returns "(empty)"
// even for non-empty directories.
cmd.env("LC_ALL", "C");
Comment on lines +38 to +42
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using LC_ALL=C forces all locale categories for the spawned ls process. That can change filename rendering/escaping and collation (and may cause non-ASCII filenames to be shown differently), even though this bug only depends on month names from LC_TIME. Prefer setting LC_TIME=C (or LC_TIME=POSIX) so date parsing is stabilized without affecting character encoding/display behavior.

Suggested change
// Force C locale so month names match LS_DATE_RE, which is English-only.
// Without this, non-English locales (e.g. LC_TIME=pt_BR.UTF-8 → "abr"/"mar")
// cause every line to fail the regex, and compact_ls returns "(empty)"
// even for non-empty directories.
cmd.env("LC_ALL", "C");
// Force only the time locale to C so month names match LS_DATE_RE,
// which is English-only. Without this, non-English locales
// (e.g. LC_TIME=pt_BR.UTF-8 → "abr"/"mar") cause every line to fail
// the regex, and compact_ls returns "(empty)" even for non-empty
// directories, while preserving other locale-sensitive output behavior.
cmd.env("LC_TIME", "C");

Copilot uses AI. Check for mistakes.
cmd.arg("-la");
for flag in &flags {
if flag.starts_with("--") {
Expand Down
Loading