diff -aupr initscripts-2009.07-3/functions initscripts-2009.07-3.new/functions --- initscripts-2009.07-3/functions 2009-07-19 22:54:32.000000000 -0400 +++ initscripts-2009.07-3.new/functions 2009-08-05 08:54:23.205528631 -0400 @@ -3,17 +3,24 @@ # # width: - -STAT_COL=$(/bin/stty size) -# strip the rows number, we just want columns -STAT_COL=${STAT_COL##* } -if [ "$STAT_COL" = "0" ]; then - # if output was 0 (serial console), set default width to 80 - STAT_COL=80 -elif [ ! -t 1 ]; then - # disable color on output to non-tty - STAT_COL=80 - USECOLOR="" +if [ -t 1 ]; then + # stty will fail when stdin isn't a terminal (but we're in this block, so stdout is) + if [ -t 0 ]; then + STAT_COL="$(/bin/stty size)" + # stty gives "rows cols"; strip the rows number, we just want columns + STAT_COL="${STAT_COL##* }" + else + # tput will fail at boot time if /usr/share/terminfo isn't yet mounted + # or TERM is otherwise unrecognized + STAT_COL="$(/bin/tput cols 2>/dev/null)" + fi + if [ "0$STAT_COL" -eq 0 ]; then + # if output was 0 (serial console), set default width to 80 + STAT_COL=80 + fi +else + STAT_COL=80 + USECOLOR="" fi # we use 13 characters for our own stuff STAT_COL=$(($STAT_COL - 13)) @@ -60,6 +67,10 @@ if [ -t 1 ]; then SAVE_POSITION="\033[s" RESTORE_POSITION="\033[u" DEL_TEXT="\033[$(($STAT_COL+4))G" +else + SAVE_POSITION="" + RESTORE_POSITION="" + DEL_TEXT="" fi # prefixes: