Changeset ddf5f77
- Timestamp:
- 06/10/2006 03:41:52 PM (18 years ago)
- Branches:
- 1.0, 2.3, 2.3.x, 2.4, ablfs, ablfs-more, legacy, new_features, trunk
- Children:
- 93f38e7
- Parents:
- 4a444f1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/progress_bar.sh
r4a444f1 rddf5f77 19 19 20 20 declare -a GRAPHIC_STR="| / - \\ + " 21 declare -i MIN=0 # Start value for minutes22 21 declare -i SEC=0 # Seconds accumulator 23 declare -i POS=0 # Start value for seconds/cursor position 22 declare -i PREV_SEC=0 23 24 24 25 25 write_or_exit() { … … 34 34 } 35 35 36 # This will loop forever.. or overflow, which ever comes first :) 37 for ((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 36 # initialize screen 37 write_or_exit "${RESET_LINE}${TS_POSITION}0 min. 0 sec. " 38 39 # loop forever.. 40 while true ; do 41 42 # Loop through the animation string 41 43 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 44 write_or_exit "${CSI}$((SEC + 3))G${GRAPHIC_CHAR}" 45 sleep .12 # This value MUST be less than .2 seconds. 45 46 done 46 # Display the accumulated time. 47 write_or_exit "${TS_POSITION}${MIN} min. ${SEC} sec. " 48 done 47 48 # A BASH internal variable, the number of seconds the script 49 # has been running. modulo convert to 0-59 50 SEC=$(($SECONDS % 60)) 51 52 # Detect rollover of the seconds. 53 (( PREV_SEC > SEC )) && write_or_exit "${RESET_LINE}" 54 (( PREV_SEC = SEC )) 55 56 # Display the accumulated time. div minutes.. modulo seconds. 57 write_or_exit "${TS_POSITION}$(($SECONDS / 60)) min. $SEC sec. " 49 58 done 59 50 60 exit 51
Note:
See TracChangeset
for help on using the changeset viewer.