From e5a85b9cbc0925a57803cfa47f4daa36e0da0cf4 Mon Sep 17 00:00:00 2001 From: David Thrane Christiansen Date: Mon, 20 Oct 2025 08:24:49 +0200 Subject: [PATCH] fix: set locale when running example commands This causes things like the sort order for `ls` to be predictable, rather than dependent on the machine. --- book/FPLean/Examples/Commands.lean | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/book/FPLean/Examples/Commands.lean b/book/FPLean/Examples/Commands.lean index b1395c1..3ca78ad 100644 --- a/book/FPLean/Examples/Commands.lean +++ b/book/FPLean/Examples/Commands.lean @@ -32,6 +32,9 @@ def requireContainer (container : Ident) : m Container := do if let some c := (containersExt.getState (← getEnv)).find? name then return c else throwErrorAt container "Not found: '{name}'" +private def localeVars : Array String := + #["LANG", "LC_ALL"] + def command (container : Ident) (dir : System.FilePath) (command : StrLit) (viaShell := false) : m IO.Process.Output := do let c ← ensureContainer container unless dir.isRelative do @@ -46,7 +49,7 @@ def command (container : Ident) (dir : System.FilePath) (command : StrLit) (viaS cmd := cmd, args := args, cwd := dir, - env := #[("PATH", some (extraPath ++ path))] + env := #[("PATH", some (extraPath ++ path))] ++ localeVars.map (·, some "C.UTF-8") } if out.exitCode != 0 then let stdout := m!"Stdout: {indentD out.stdout}"