diff options
-rw-r--r-- | functions | 60 | ||||
-rwxr-xr-x | rc.sysinit | 3 |
2 files changed, 35 insertions, 28 deletions
@@ -4,26 +4,40 @@ # width: -STAT_COL=80 -if [[ ! -t 1 ]]; then - USECOLOR="" -elif [[ -t 0 ]]; then - # stty will fail when stdin isn't a terminal - STAT_COL="$(/bin/stty size)" - # stty gives "rows cols"; strip the rows number, we just want columns - STAT_COL="${STAT_COL##* }" -elif /bin/tput cols &>/dev/null; then - # is /usr/share/terminfo already mounted, and TERM recognized? - STAT_COL=$(/bin/tput cols) -fi -if ((STAT_COL==0)); then - # if output was 0 (serial console), set default width to 80 +calc_columns () { STAT_COL=80 - USECOLOR="" -fi + if [[ ! -t 1 ]]; then + USECOLOR="" + elif [[ -t 0 ]]; then + # stty will fail when stdin isn't a terminal + STAT_COL="$(/bin/stty size)" + # stty gives "rows cols"; strip the rows number, we just want columns + STAT_COL="${STAT_COL##* }" + elif /bin/tput cols &>/dev/null; then + # is /usr/share/terminfo already mounted, and TERM recognized? + STAT_COL=$(/bin/tput cols) + fi + if ((STAT_COL==0)); then + # if output was 0 (serial console), set default width to 80 + STAT_COL=80 + USECOLOR="" + fi + + # we use 13 characters for our own stuff + STAT_COL=$(($STAT_COL - 13)) + + if [[ -t 1 ]]; then + SAVE_POSITION="\e[s" + RESTORE_POSITION="\e[u" + DEL_TEXT="\e[$(($STAT_COL+4))G" + else + SAVE_POSITION="" + RESTORE_POSITION="" + DEL_TEXT="" + fi +} -# we use 13 characters for our own stuff -STAT_COL=$(($STAT_COL - 13)) +calc_columns # disable colors on broken terminals TERM_COLORS="$(/bin/tput colors 2>/dev/null)" @@ -76,16 +90,6 @@ if [[ $USECOLOR =~ yes|YES ]]; then fi fi -if [[ -t 1 ]]; then - SAVE_POSITION="\e[s" - RESTORE_POSITION="\e[u" - DEL_TEXT="\e[$(($STAT_COL+4))G" -else - SAVE_POSITION="" - RESTORE_POSITION="" - DEL_TEXT="" -fi - # prefixes: PREFIX_REG="::" @@ -95,6 +95,9 @@ unset mods status "Waiting for UDev uevents to be processed" \ udevadm settle --timeout=${UDEV_TIMEOUT:-30} +# in case loading a module changed the display mode +calc_columns + run_hook sysinit_udevsettled # bring up the loopback interface |