mirror of
https://github.com/l0ng-ai/tty7.git
synced 2026-09-23 00:02:27 +00:00
The GUI-launch locale fallback exported a literal `LC_CTYPE=UTF-8`. That name is a BSD libc alias with no glibc equivalent, and the stock `ssh_config` ships `SendEnv LANG LC_*`, so it rode along to every host we ssh into. There `LC_CTYPE` outranks the `LANG` the host sets for itself and then fails to load, dropping the remote shell to the C locale -- re-creating the mangled non-ASCII output the fallback exists to prevent. Derive the locale from the system locale instead, the way Terminal.app and iTerm2 do: reduce the CFLocale identifier to its POSIX `lang_REGION` stem, and fall back to `C.UTF-8` then `en_US.UTF-8`. Every candidate is checked against `/usr/share/locale` before it is exported, so tty7 never hands a shell a name the C library cannot load -- including on machines whose region combination has no installed locale (`en_CN` is an ordinary macOS setting that resolves to no locale at all). Still `LC_CTYPE` only, and still only when no locale is inherited or configured, so message/date/number localization and explicit user overrides are untouched. Fixes #178