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 | |
parent | e3c06e981af869d6a00ec8cde34bde1e15cb53ad (diff) |
upgpkg: initscripts 2007.08-2
-rw-r--r-- | functions | 26 | ||||
-rwxr-xr-x | rc.sysinit | 4 |
2 files changed, 23 insertions, 7 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() { @@ -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 |