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=$$'?25l'
declare -r CURSOR_ON=$$'?25h'
declare -r ERASE_LINE=$$'2K'
declare -r FRAME_OPEN=$$'2G['
declare -r FRAME_CLOSE=$$'63G]'
declare -r TS_POSITION=$$'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 "\
$\
$\
$\
$\
$$ min. $ 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 $ ; do
# If the target build is complete.. just leave
[[ -f $1 ]] && echo -n
"$" && exit
echo -ne "$$(($ +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 "$" && 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
"$$$"
fi
# Display the accumulated time.
echo -n "$$ min. $
sec."
done
fi
echo -n "$"
--
http://linuxfromscratch.org/mailman/listinfo/alfs-discu
ss
FAQ: http://www.linux
fromscratch.org/faq/
Unsubscribe: See the above information page
|