--- toast-linux 2004/04/25 05:08:26 1.53 +++ toast-linux 2004/04/25 22:35:13 1.54 @@ -996,6 +996,7 @@ if [ "$1" = "init" ]; then [ -n "$TASK_INIT" ] && exit 0 shift + for i in `seq 1 25`; do echo; done TASK_INIT=1 exec "$@" fi @@ -1017,10 +1018,24 @@ [ -s "$file" ] && exit 0 +hms() +{ + local h m s + case "$1" in + [0-9]*) + let h="$1/3600" + let m="($1/60)%60" + let s="$1%60" + printf "%d:%02d:%02d\n" "$h" "$m" "$s" + ;; + *) + echo "?:??:??" + ;; + esac +} out="" p() { out="$out$*"; } firstline=4 -p '\33[s\33[H' line="" etotal=0 atotal=0 @@ -1044,11 +1059,15 @@ p "$n" p '\33[0;44m' done < "$list" -remain="?" +remain="" +this="" if [ "$esofar" -gt 0 -a "$asofar" -gt 0 ]; then let remain="($etotal-$esofar)*$asofar/$esofar" + let this="$estimate*$asofar/$esofar" fi -p '\33[K\12\33[0;1;42m'"$asofar seconds elapsed; $remain remaining"'\33[K\12\16\33[1;33;43m' +let percent="$esofar*100/$etotal" +out='\33[s\33[H\33[0;1;42m'"`hms $asofar` elapsed / $percent% complete = `hms $remain` left ($name: `hms $this`)"'\33[K\12'"$out" +p '\33[K\12\16\33[1;33;43m' let bar="$esofar*80/$etotal" while [ "$bar" -gt 0 ]; do p '0'