- Timestamp:
- 04/13/2019 04:33:38 PM (5 years ago)
- Branches:
- ablfs-more, legacy, trunk
- Children:
- c048987
- Parents:
- 0e4ddfa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/progress_bar.sh
r0e4ddfa rbc2f591 1 1 # shellcheck shell=bash 2 2 # $Id$ 3 3 … … 16 16 declare -r FRAME_CLOSE=${CSI}$'63G]' 17 17 declare -r TS_POSITION=${CSI}$'65G' 18 declare -r LINE_WRAP_OFF=${CSI}$'?7l' 19 declare -r LINE_WRAP_ON=${CSI}$'?7h' 20 declare -a RESET_LINE=${CURSOR_OFF}${ERASE_LINE}${FRAME_OPEN}${FRAME_CLOSE} 18 declare -r RESET_LINE=${CURSOR_OFF}${ERASE_LINE}${FRAME_OPEN}${FRAME_CLOSE} 21 19 22 declare - aGRAPHIC_STR="| / - \\ + "20 declare -r GRAPHIC_STR="| / - \\ + " 23 21 declare -i SEC=0 # Seconds accumulator 24 22 declare -i PREV_SEC=0 … … 50 48 while true ; do 51 49 52 53 54 55 56 50 # Loop through the animation string 51 for GRAPHIC_CHAR in ${GRAPHIC_STR} ; do 52 write_or_exit "${CSI}$((SEC + 3))G${GRAPHIC_CHAR}" 53 $SLEEP .12 # This value MUST be less than .2 seconds. 54 done 57 55 58 59 60 SEC=$(($SECONDS % 60))56 # A BASH internal variable, the number of seconds the script 57 # has been running. modulo convert to 0-59 58 SEC=$((SECONDS % 60)) 61 59 62 63 64 60 # Detect rollover of the seconds. 61 (( PREV_SEC > SEC )) && write_or_exit "${RESET_LINE}" 62 PREV_SEC=$SEC 65 63 66 67 write_or_exit "${TS_POSITION}$(($SECONDS / 60)) min. $SEC sec"64 # Display the accumulated time. div minutes.. modulo seconds. 65 write_or_exit "${TS_POSITION}$((SECONDS / 60)) min. $SEC sec" 68 66 done 69 67
Note:
See TracChangeset
for help on using the changeset viewer.