aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-08-15 04:01:59 +0000
committerDan McGee <dan@archlinux.org>2007-08-15 04:01:59 +0000
commit8649f79e8e0027bd46da8b13f6d8ac5465471c35 (patch)
treeb4d48343f67dd4fd7d9ab7dbf55f18c51f33e969
parente3c06e981af869d6a00ec8cde34bde1e15cb53ad (diff)
downloadinitscripts-8649f79e8e0027bd46da8b13f6d8ac5465471c35.tar.xz
upgpkg: initscripts 2007.08-2
-rw-r--r--functions26
-rwxr-xr-xrc.sysinit4
2 files changed, 23 insertions, 7 deletions
diff --git a/functions b/functions
index a43d3a2..961f376 100644
--- a/functions
+++ b/functions
@@ -3,12 +3,25 @@
# functions
#
-STAT_COL=$[`stty size | awk 'BEGIN { RS=" " }; END { print $1 }'` - 13]
+# width:
+
+STAT_COL=$(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=""
+fi
+# we use 13 characters for our own stuff
+STAT_COL=$[$STAT_COL - 13]
# colors:
if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then
-
C_MAIN="\033[1;37m" # main text
C_OTHER="\033[1;34m" # prefix & brackets
C_SEPARATOR="\033[1;30m" # separator
@@ -24,8 +37,11 @@ if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then
C_CLEAR="\033[1;0m"
fi
-SAVE_POSITION="\033[s"
-RESTORE_POSITION="\033[u"
+if [ -t 1 ]; then
+ SAVE_POSITION="\033[s"
+ RESTORE_POSITION="\033[u"
+ DEL_TEXT="\033[$(($STAT_COL+4))G"
+fi
# prefixes:
@@ -35,7 +51,7 @@ PREFIX_HL=" >"
# functions:
deltext() {
- echo -ne "\033[$(($STAT_COL+4))G"
+ echo -ne "$DEL_TEXT"
}
printhl() {
diff --git a/rc.sysinit b/rc.sysinit
index 3e27a8e..b577707 100755
--- a/rc.sysinit
+++ b/rc.sysinit
@@ -341,7 +341,7 @@ if [ "$(echo $LOCALE | /bin/grep -i utf)" ]; then
/usr/bin/kbd_mode -u
/usr/bin/dumpkeys | /bin/loadkeys --unicode
# the $CONSOLE check helps us avoid this when running scripts from cron
- echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a isatty ]; then echo -ne "\e%G"; fi' >>/etc/profile.d/locale.sh
+ echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then echo -ne "\e%G"; fi' >>/etc/profile.d/locale.sh
stat_done
fi
@@ -355,7 +355,7 @@ if [ "$CONSOLEFONT" != "" ]; then
fi
done
# the $CONSOLE check helps us avoid this when running scripts from cron
- echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a isatty ]; then echo -ne "\e(K"; fi' >>/etc/profile.d/locale.sh
+ echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then echo -ne "\e(K"; fi' >>/etc/profile.d/locale.sh
stat_done
fi
# Adding persistent network/cdrom generated rules