[arch-general] [PATCH 38/48] Bashify locale setting.

Victor Lowther victor.lowther at gmail.com
Wed Jun 30 17:47:45 EDT 2010


---
 rc.sysinit |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/rc.sysinit b/rc.sysinit
index 5842a57..c6ed35f 100755
--- a/rc.sysinit
+++ b/rc.sysinit
@@ -303,12 +303,12 @@ status "Updating Module Dependencies" /sbin/depmod -A
 : >| /etc/profile.d/locale.sh
 /bin/chmod 755 /etc/profile.d/locale.sh
 # Set user defined locale
-[ -z "$LOCALE" ] && LOCALE="en_US"
+[[ $LOCALE ]] || LOCALE="en_US"
 stat_busy "Setting Locale: $LOCALE"
 echo "export LANG=$LOCALE" >>/etc/profile.d/locale.sh
 stat_done
 
-if echo "$LOCALE" | /bin/grep -qi utf ; then
+if [[ $LOCALE =~ utf|UTF ]]; then
 	stat_busy "Setting Consoles to UTF-8 mode"
 	# UTF-8 consoles are default since 2.6.24 kernel
 	# this code is needed not only for older kernels,
@@ -318,9 +318,11 @@ if echo "$LOCALE" | /bin/grep -qi utf ; then
 		printf "\033%%G" > ${i}
 	done
 	# the $CONSOLE check helps us avoid this when running scripts from cron
-	echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "\033%%G"; fi' >>/etc/profile.d/locale.sh
+	cat <<"EOF" >>/etc/profile.d/locale.sh
+if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "\033%%G"; fi
+EOF
 	stat_done
-	[ -n "$KEYMAP" ] && status "Loading Keyboard Map: $KEYMAP" /bin/loadkeys -q -u $KEYMAP
+	[[ $KEYMAP ]] && status "Loading Keyboard Map: $KEYMAP" /bin/loadkeys -q -u "$KEYMAP"
 else
 	stat_busy "Setting Consoles to legacy mode"
 	# make non-UTF-8 consoles work on 2.6.24 and newer kernels
@@ -329,9 +331,11 @@ else
 		printf "\033%%@" > ${i}
 	done
 	# the $CONSOLE check helps us avoid this when running scripts from cron
-	echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "\033%%@"; fi' >>/etc/profile.d/locale.sh
+	cat <<"EOF" >>/etc/profile.d/locale.sh
+if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "\033%%@"; fi
+EOF
 	stat_done
-	[ -n "$KEYMAP" ] && status "Loading Keyboard Map: $KEYMAP" /bin/loadkeys -q $KEYMAP
+	[[ $KEYMAP ]] && status "Loading Keyboard Map: $KEYMAP" /bin/loadkeys -q $KEYMAP
 fi
 
 # Set console font if required
-- 
1.7.1



More information about the arch-general mailing list