diff --git a/functions b/functions index 909b756..a878df7 100644 --- a/functions +++ b/functions @@ -5,25 +5,38 @@ # width: STAT_COL=80 -if [[ ! -t 1 ]]; then +calc_columns() { + if [ ! -t 1 ]; then USECOLOR="" -elif [[ -t 0 ]]; then - # stty will fail when stdin isn't a terminal + # stty will fail when stdin isn't a terminal + elif [ -t 0 ]; then 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 + 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="\033[s" + RESTORE_POSITION="\033[u" + DEL_TEXT="\033[$(($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)" diff --git a/rc.multi b/rc.multi index 660f649..a66e779 100755 --- a/rc.multi +++ b/rc.multi @@ -15,8 +15,12 @@ run_hook multi_start for daemon in "${DAEMONS[@]}"; do case ${daemon:0:1} in '!') continue;; # Skip this daemon. - '@') start_daemon_bkgd "${daemon#@}";; - *) start_daemon "$daemon";; + '@') + start_daemon_bkgd "${daemon#@}" + calc_columns;; + *) + start_daemon "$daemon" + calc_columns;; esac done diff --git a/rc.sysinit b/rc.sysinit index 44c3eac..fc561d6 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -76,6 +76,7 @@ echo > /proc/sys/kernel/hotplug stat_busy "Starting UDev Daemon" /sbin/udevd --daemon +calc_columns stat_done run_hook sysinit_udevlaunched @@ -86,6 +87,7 @@ if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then /sbin/udevadm control --property=STARTUP=1 /sbin/udevadm trigger --action=add --type=devices /sbin/udevadm trigger --action=add --type=subsystems + calc_columns stat_done fi @@ -94,6 +96,7 @@ mods=${MODULES[@]/!*/} if [[ $load_modules != off && -f /proc/modules && $mods ]]; then stat_busy "Loading Modules" /sbin/modprobe --all $mods + calc_columns stat_done fi unset mods @@ -103,6 +106,7 @@ if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then stat_busy "Waiting for UDev uevents to be processed" /sbin/udevadm settle /sbin/udevadm control --property=STARTUP= + calc_columns stat_done fi