Author: glen
Date: Thu Dec 27 01:52:36 2007
New Revision: 9162

Modified:
   rc-scripts/trunk/rc.d/init.d/functions
Log:
- handle when there's no terminal attached (f.e gui tools like smart)

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      Thu Dec 27 01:52:36 2007
@@ -46,7 +46,6 @@
 [ -r /etc/sysconfig/init-colors ] && . /etc/sysconfig/init-colors
 [ -r /etc/sysconfig/system ] && . /etc/sysconfig/system
 [ -r /etc/sysconfig/bootsplash ] && . /etc/sysconfig/bootsplash
-
 [ -z "$COLUMNS" ] && COLUMNS=80
 
 if [ -z "$VSERVER" -o "$VSERVER" = "detect" ]; then
@@ -63,6 +62,11 @@
        unset _f _ctx
 fi
 
+# we need to know in functions if we were called from a terminal
+if [ -z "$ISATTY" ]; then
+       [ -t ] && ISATTY=yes || ISATTY=no
+fi
+
 is_yes()
 {
        # Test syntax
@@ -197,6 +201,7 @@
 # Colors workaround
 termput()
 {
+       is_yes "$ISATTY" || return
 
        if is_yes "$FASTRC" || is_no "$TPUT"; then
                case "$1" in
@@ -924,9 +929,16 @@
        # If we don't, create memory variables and try to save silently,
        local cachefile='/var/cache/rc-scripts/msg.cache'
 
+       local term
+       if is_yes "$ISATTY"; then
+               term=$TERM
+       else
+               term=dumb
+       fi
+
        # We create $check variable which is used to invalidate the cache.
        # The $check contains user locale and terminal.
-       local check="$TERM.$LC_MESSAGES"
+       local check="$term.$LC_MESSAGES"
 
        if [ -f "$cachefile" -a "$cachefile" -nt /etc/sysconfig/system -a 
"$cachefile" -nt /etc/sysconfig/init-colors ]; then
                if . "$cachefile" 2>/dev/null; then
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to