locale-setup: default to C.UTF-8
authorLennart Poettering <lennart@poettering.net>
Mon, 12 Nov 2018 12:12:39 +0000 (13:12 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 14 Nov 2018 16:01:54 +0000 (17:01 +0100)
Most distributions already were shipping a C.UTF-8 locale and even Fedora
now supports the C.UTF-8 locale, and there's clear indication that this
is going upstream too. Hence, let's default to it now too, if nothing
else is set.

Note that this is only a fallback if noting else is set, and since
distros generally configure a default for this behaviour shouldn't
really change in installed systems.

On new systems this makes vconsole.conf redundant.

src/core/locale-setup.c

index 5fd5477..dc61576 100644 (file)
@@ -79,16 +79,28 @@ int locale_setup(char ***environment) {
                 }
         }
 
-        if (!strv_isempty(add)) {
-                char **e;
+        if (strv_isempty(add)) {
+                /* If no locale is configured then default to C.UTF-8. */
 
-                e = strv_env_merge(2, *environment, add);
-                if (!e) {
+                add = strv_new("LANG=C.UTF-8");
+                if (!add) {
+                        r = -ENOMEM;
+                        goto finish;
+                }
+        }
+
+        if (strv_isempty(*environment))
+                strv_free_and_replace(*environment, add);
+        else {
+                char **merged;
+
+                merged = strv_env_merge(2, *environment, add);
+                if (!merged) {
                         r = -ENOMEM;
                         goto finish;
                 }
 
-                strv_free_and_replace(*environment, e);
+                strv_free_and_replace(*environment, merged);
         }
 
         r = 0;