Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.

Commit 8c875a1

Browse files
committed
B #251: Improve locale handling
- Change the value to 'C' (POSIX) which is more generic - LANG can be insufficiant and will not override LC_TIME for example if that was set - LC_ALL will ensure that all categories of locale are POSIX C - This commit also provides a way for the scripts to find the original locale via '_one_orig_*' variables if that would be needed Signed-off-by: Petr Ospalý <pospaly@opennebula.io>
1 parent 74385d0 commit 8c875a1

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

src/usr/sbin/one-contextd

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
# -------------------------------------------------------------------------- #
4-
# Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
4+
# Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
55
# #
66
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
77
# not use this file except in compliance with the License. You may obtain #
@@ -18,7 +18,22 @@
1818

1919
set -e
2020

21-
export LANG=C.UTF-8
21+
# Save original locale variables and enforce POSIX C locale
22+
#
23+
# We provide the user a way to fallback to the correct locale when a command
24+
# should or must respect system's locale by saving the original values into the
25+
# '_one_orig*' variables...
26+
27+
export _one_orig_LANG="${LANG}"
28+
export _one_orig_LC_ALL="${LC_ALL}"
29+
export _one_orig_LC_COLLATE="${LC_COLLATE}"
30+
export _one_orig_LC_CTYPE="${LC_CTYPE}"
31+
export _one_orig_LC_MESSAGES="${LC_MESSAGES}"
32+
export _one_orig_LC_MONETARY="${LC_MONETARY}"
33+
export _one_orig_LC_NUMERIC="${LC_NUMERIC}"
34+
export _one_orig_LC_TIME="${LC_TIME}"
35+
export LANG=C
36+
export LC_ALL=C
2237

2338
TYPE="${1:-all}" # local, online, network, all
2439
COMMAND="${2}" # force, reconfigure?

0 commit comments

Comments
 (0)