]> git.pld-linux.org Git - projects/rc-scripts.git/commitdiff
- handle when there's no terminal attached (f.e gui tools like smart)
authorElan Ruusamäe <glen@pld-linux.org>
Thu, 27 Dec 2007 00:52:36 +0000 (00:52 +0000)
committerElan Ruusamäe <glen@pld-linux.org>
Thu, 27 Dec 2007 00:52:36 +0000 (00:52 +0000)
svn-id: @9162

rc.d/init.d/functions

index 2306850cb84fe4511c3486fa1f398f3457a5f575..ed487cb4b14bf19dc273d6f781f67e75678a0433 100644 (file)
@@ -46,7 +46,6 @@ CCHARS="$NORMAL"      # Color of these characters (look at /etc/sysconfig/init-colors
 [ -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 @@ if [ -z "$VSERVER" -o "$VSERVER" = "detect" ]; then
        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 @@ kernelvermser()
 # Colors workaround
 termput()
 {
+       is_yes "$ISATTY" || return
 
        if is_yes "$FASTRC" || is_no "$TPUT"; then
                case "$1" in
@@ -924,9 +929,16 @@ rc_cache_init() {
        # 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
This page took 0.095656 seconds and 4 git commands to generate.