[arch-projects] [initscripts][PATCH 5/7] functions: declare locale vars in an array for reuse

Dave Reisner d at falconindy.com
Sun Nov 6 19:27:39 EST 2011


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 at archlinux.org>
---
 functions |   17 +++++++++--------
 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
-- 
1.7.7.2



More information about the arch-projects mailing list