Manuel,
I found a few < gotcha's > in the code I sent you. Most are caused by the lack of a synchronization between progress_bar and the makefile. <progress_bar.sh> is asynchronous and there is not much that can be done. The program wakes up, writes to the screen and then checks to see if should exit. This is a problem if the target build completes while the progress bar is asleep. The makefile outputs a trace for the next target build and the screen text becomes messy. I added some new traps and moved other completion traps around. The screen stays clean now. (except that 'scroll-lock' will stall the display and invalidate the counter)

  George

#!/bin/bash

set -e

# Be sure that we know the target name
[[ -z $1 ]] && exit

declare -r  CSI=$'\e['  # DEC terminology, Control Sequence Introducer
declare -r  CURSOR_OFF=${CSI}$'?25l'
declare -r  CURSOR_ON=${CSI}$'?25h'
declare -r  ERASE_LINE=${CSI}$'2K'
declare -r  FRAME_OPEN=${CSI}$'2G['
declare -r  FRAME_CLOSE=${CSI}$'63G]'
declare -r  TS_POSITION=${CSI}$'65G'    # Time Stamp
declare -a  GRAPHIC_STR="| / - \\ . "
declare -i  MIN=0  # Start value for minutes
declare -i  POS=0  # Start value for seconds/cursor position

# Initialize the display line.
echo -n "\
${CURSOR_OFF}\
${ERASE_LINE}\
${FRAME_OPEN}\
${FRAME_CLOSE}\
${TS_POSITION}${MIN} min. ${POS} sec."

# A failsafe, target may be built
if [ ! -f $1 ] ; then
    # While make is alive
  while fuser -v . 2>&1 | grep make >/dev/null ; do
      # A little animation at the current position
    for i in ${GRAPHIC_STR} ; do
        # If the target build is complete.. just leave
      [[ -f $1 ]] && echo -n "${CURSOR_ON}" && exit

      echo -ne "${CSI}$((${POS} +3))G$i"
      sleep .2

        # Don't miss default prompt if make fails while we were asleep
      if ! fuser -v . 2>&1 | grep make >/dev/null ; then
        echo -n "${CURSOR_ON}" && exit
      fi
    done
      # Be sure to exit cleanly
      # target may have completed while we were asleep
    [[ -f $1 ]] && break

      # Increment position and seconds counter
    ((POS++))
      # Minutes counter
    if [[ "$POS" = "60" ]] ; then
      POS=0
      ((MIN++))
      echo -n "${ERASE_LINE}${FRAME_OPEN}${FRAME_CLOSE}"
    fi
      # Display the accumulated time.
    echo -n "${TS_POSITION}${MIN} min. ${POS} sec."
  done
fi
echo -n "${CURSOR_ON}"
--
http://linuxfromscratch.org/mailman/listinfo/alfs-discuss
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to