summaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorAaron Griffin <aaronmgriffin@gmail.com>2009-07-30 20:15:31 -0700
committerAaron Griffin <aaronmgriffin@gmail.com>2009-07-30 20:15:31 -0700
commitb05933da4de82fe515c1eee5e5a7690072b99c79 (patch)
tree5c80fd19c11dd874e2e2d73a4db73b734c5ff180 /functions
parent7a1b906ca77f83c2e1956bdc04a1e822239465ea (diff)
functions: refactor for non-tty output
This commit should allow rc.d scripts to be run from non-tty's, such as a cron job Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
Diffstat (limited to 'functions')
-rw-r--r--functions25
1 files changed, 15 insertions, 10 deletions
diff --git a/functions b/functions
index f84fb5e..96903b9 100644
--- a/functions
+++ b/functions
@@ -4,16 +4,17 @@
# 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=""
+# disable color on output to non-tty
+STAT_COL=80
+USECOLOR=""
+if [ -t 1 ]; then
+ 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
+ fi
fi
# we use 13 characters for our own stuff
STAT_COL=$(($STAT_COL - 13))
@@ -60,6 +61,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: