source: common/progress_bar.sh@ e2ef100

1.0 2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since e2ef100 was e2ef100, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Added " Target $@ OK" lines to the Makefile output.
Made more accurate the time meassured by progress_bar.sh.

  • Property mode set to 100755
File size: 1.5 KB
Line 
1#!/bin/bash
2
3# $Id$
4
5set -e
6
7# Be sure that we know the taget name
8[[ -z $1 ]] && exit
9TARGET=$1 # Remember the target build we are looking for
10
11declare -r CSI=$'\e[' # DEC terminology, Control Sequence Introducer
12declare -r CURSOR_OFF=${CSI}$'?25l'
13declare -r CURSOR_ON=${CSI}$'?25h'
14declare -r ERASE_LINE=${CSI}$'2K'
15declare -r FRAME_OPEN=${CSI}$'2G['
16declare -r FRAME_CLOSE=${CSI}$'63G]'
17declare -r TS_POSITION=${CSI}$'65G'
18declare -a RESET_LINE=${CURSOR_OFF}${ERASE_LINE}${FRAME_OPEN}${FRAME_CLOSE}
19
20declare -a GRAPHIC_STR="| / - \\ + "
21declare -i MIN=0 # Start value for minutes
22declare -i SEC=0 # Seconds accumulator
23declare -i POS=0 # Start value for seconds/cursor position
24
25write_or_exit() {
26 # make has been killed or failed or run to completion, leave
27 if ! fuser -v . 2>&1 | grep make >/dev/null ; then
28 echo -n "${CURSOR_ON}" && exit
29 fi
30 # Target build complete, leave.
31 [[ -f ${TARGET} ]] && echo -n "${CURSOR_ON}" && exit
32 # It is safe to write to the screen
33 echo -n "$1"
34}
35
36 # This will loop forever.. or overflow, which ever comes first :)
37for ((MIN=0; MIN >= 0; MIN++)); do
38 write_or_exit "${RESET_LINE}${TS_POSITION}${MIN} min. 0 sec. "
39 # Count the seconds
40 for ((SEC=1, POS=3; SEC <= 60; SEC++, POS++)); do
41 for GRAPHIC_CHAR in ${GRAPHIC_STR} ; do
42 write_or_exit "${CSI}${POS}G${GRAPHIC_CHAR}"
43 # Compensate code execution time (need verification on other machines)
44 sleep .137
45 done
46 # Display the accumulated time.
47 write_or_exit "${TS_POSITION}${MIN} min. ${SEC} sec. "
48 done
49done
50exit
51
Note: See TracBrowser for help on using the repository browser.