mirror of
https://codeberg.org/guix/guix.git
synced 2026-01-25 12:05:19 -06:00
guile-launcher: Avoid the “C” locale and try “C.UTF-8”.
This is a followup toed0cd12a82, which adds the C.UTF-8 locale to the glibc package, andee4e79f871, which changed the default to “C.UTF-8” for ‘guix’ commands. Fixes a bug whereby starting ‘guix’ in an environment where the LC_* variables are unset would start it in the “C” locale: echo '(pk (setlocale LC_ALL))' | guix shell -CW coreutils -- guix repl This would lead to breakage for commands such as ‘guix substitute’ that need to run in a UTF-8 locale. * gnu/packages/aux-files/guile-launcher.c (main): Try “C.UTF-8” before “en_US.UTF-8”. Do that also when the current locale is “C”. * guix/ui.scm (install-locale): Likewise. Change-Id: I36da4db8f898f1083b33760e1ab46c3a257de811
This commit is contained in:
parent
889d1b0e4a
commit
d7c8a5ff3c
2 changed files with 14 additions and 6 deletions
|
|
@ -84,11 +84,17 @@ int
|
|||
main (int argc, char **argv)
|
||||
{
|
||||
/* Try to install the current locale; remain silent if it fails. */
|
||||
if (setlocale (LC_ALL, "") == NULL)
|
||||
/* The 'guix pull'-provided 'guix' includes at least en_US.utf8 so use
|
||||
that. That gives us UTF-8 support for 'scm_to_locale_string', etc.,
|
||||
which is always preferable over the C locale. */
|
||||
setlocale (LC_ALL, "en_US.utf8");
|
||||
char *locale = setlocale (LC_ALL, "");
|
||||
if (locale == NULL || strcmp (locale, "C") == 0)
|
||||
{
|
||||
/* The 'guix pull'-provided 'guix' includes at least C.UTF-8 (which is
|
||||
baked into glibc, except when cross-compiling) so use that, and fall
|
||||
back to en_US.UTF-8. That gives us UTF-8 support for
|
||||
'scm_to_locale_string', etc., which is always preferable over the C
|
||||
locale. */
|
||||
if (setlocale (LC_ALL, "C.UTF-8") == NULL)
|
||||
setlocale (LC_ALL, "en_US.utf8");
|
||||
}
|
||||
|
||||
const char *str;
|
||||
str = getenv ("GUILE_LOAD_PATH");
|
||||
|
|
|
|||
|
|
@ -521,7 +521,9 @@ part."
|
|||
"Install the current locale settings."
|
||||
(catch 'system-error
|
||||
(lambda _
|
||||
(setlocale LC_ALL ""))
|
||||
(when (string=? (setlocale LC_ALL "") "C")
|
||||
;; If the current locale is "C", prefer "C.UTF-8".
|
||||
(setlocale LC_ALL "C.UTF-8")))
|
||||
(lambda args
|
||||
(display-hint (G_ "Consider installing the @code{glibc-locales} package
|
||||
and defining @code{GUIX_LOCPATH}, along these lines:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue