summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2011-11-06 19:00:10 -0500
committerDave Reisner <dreisner@archlinux.org>2011-11-06 19:15:52 -0500
commitfe1695420fab1476dec28d70b91282c9b30d161e (patch)
tree9e17982a0412220c700f5810033dab5ca38dad59
parentdbcb6ce2da54cca82dc0b46e92ed028f79ea4336 (diff)
functions: declare locale vars in an array for reuse
This also fixes a bug that unintentionally sets LOCALE instead of just defaulting to a value when its empty. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
-rw-r--r--functions17
1 files changed, 9 insertions, 8 deletions
diff --git a/functions b/functions
index 7de58c1..ce664ed 100644
--- a/functions
+++ b/functions
@@ -5,6 +5,10 @@
# sanitize PATH (will be overridden later when /etc/profile is sourced, but is useful for UDev)
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+localevars=(LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY
+ LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE
+ LC_MEASUREMENT LC_IDENTIFICATION LC_ALL)
+
if [[ $1 == "start" ]]; then
if [[ $STARTING ]]; then
echo "A daemon is starting another daemon, this is unlikely to work as intended."
@@ -64,17 +68,14 @@ unset TERM_COLORS
unset TZ
# sanitize the locale settins
-unset LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \
- LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE \
- LC_MEASUREMENT LC_IDENTIFICATION LC_ALL
+unset "${localevars[@]}"
+
if [[ $DAEMON_LOCALE = [yY][eE][sS] ]]; then
- LANG="${LOCALE:=C}"
- if [ -r /etc/locale.conf ]; then
+ LANG=${LOCALE:-C}
+ if [[ -r /etc/locale.conf ]]; then
. /etc/locale.conf
fi
- export LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \
- LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE \
- LC_MEASUREMENT LC_IDENTIFICATION LC_ALL
+ export "${localevars[@]}"
else
export LANG=C
fi