SVN: rc-scripts/trunk/rc.d/init.d/functions

glen glen at pld-linux.org
Sun Sep 17 17:13:53 CEST 2006


Author: glen
Date: Sun Sep 17 17:13:53 2006
New Revision: 7765

Modified:
   rc-scripts/trunk/rc.d/init.d/functions
Log:
Keep state of have gettext and have tput per whole initscript.

Modified: rc-scripts/trunk/rc.d/init.d/functions
==============================================================================
--- rc-scripts/trunk/rc.d/init.d/functions	(original)
+++ rc-scripts/trunk/rc.d/init.d/functions	Sun Sep 17 17:13:53 2006
@@ -66,6 +66,24 @@
 	FASTRC=yes
 fi
 
+if [ -z "$GETTEXT" ]; then
+	if [ -x /bin/gettext -o -x /usr/bin/gettext ]; then
+		GETTEXT=yes
+	else
+		GETTEXT=no
+	fi
+fi
+
+if [ -n "$TPUT" ]; then
+	if [ -d /usr/share/terminfo ] && [ -x /usr/bin/tput -o -x /bin/tput ] ; then
+		TPUT=yes
+		# check if we are on proper terminal
+		tput longname >/dev/null 2>&1 || TPUT=no
+	else
+		TPUT=no
+	fi
+fi
+
 is_yes()
 {
 	# Test syntax
@@ -151,16 +169,8 @@
 # Colors workaround
 termput()
 {
-	typeset tputavail
 
-	if [ -d /usr/share/terminfo ] && [ -x /usr/bin/tput -o -x /bin/tput ] ; then
-		tputavail=yes
-		# check if we are on proper terminal
-		tput longname >/dev/null 2>&1 || tputavail=no
-	else
-		tputavail=no
-	fi
-	if is_yes "$FASTRC" || is_no "$tputavail"; then
+	if is_yes "$FASTRC" || is_no "$TPUT"; then
 		case "$1" in
 		  hpa)
 			echo -ne "\033[$(($2+1))G"
@@ -252,7 +262,7 @@
 
 	if is_yes "$FASTRC"; then
 		printf "$message" "$@"
-	elif [ -x /bin/gettext -o -x /usr/bin/gettext ]; then
+	elif is_yes "$GETTEXT"; then
 		text=$(TEXTDOMAINDIR="/etc/sysconfig/locale" gettext -e --domain="${NLS_DOMAIN:-rc-scripts}" "$message")
 		printf "$text" "$@"
 	else


More information about the pld-cvs-commit mailing list