diff options
author | Dan McGee <dan@archlinux.org> | 2007-08-15 04:01:59 +0000 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-08-15 04:01:59 +0000 |
commit | 8649f79e8e0027bd46da8b13f6d8ac5465471c35 (patch) | |
tree | b4d48343f67dd4fd7d9ab7dbf55f18c51f33e969 /functions | |
parent | e3c06e981af869d6a00ec8cde34bde1e15cb53ad (diff) | |
download | initscripts-8649f79e8e0027bd46da8b13f6d8ac5465471c35.tar.xz |
upgpkg: initscripts 2007.08-2
Diffstat (limited to 'functions')
-rw-r--r-- | functions | 26 |
1 files changed, 21 insertions, 5 deletions
@@ -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() { |