diff options
author | Aaron Griffin <aaronmgriffin@gmail.com> | 2009-07-30 20:15:31 -0700 |
---|---|---|
committer | Aaron Griffin <aaronmgriffin@gmail.com> | 2009-07-30 20:15:31 -0700 |
commit | b05933da4de82fe515c1eee5e5a7690072b99c79 (patch) | |
tree | 5c80fd19c11dd874e2e2d73a4db73b734c5ff180 /functions | |
parent | 7a1b906ca77f83c2e1956bdc04a1e822239465ea (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-- | functions | 25 |
1 files changed, 15 insertions, 10 deletions
@@ -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: |