Loading src/progress.sh +18 −11 Original line number Diff line number Diff line #!/usr/bin/env bash set -Eeuo pipefail info="/run/shm/msg.html" escape () { local s s=${1//&/\&} Loading @@ -14,16 +16,20 @@ escape () { file="$1" total="$2" body=$(escape "$3") info="/run/shm/msg.html" if [[ "$body" == *"..." ]]; then body="<p class=\"loading\">${body/.../}</p>" body="<p class=\"loading\">${body::-3}</p>" fi while true do if [ -s "$file" ]; then if [ ! -s "$file" ] && [ ! -d "$file" ]; then bytes="0" else bytes=$(du -sb "$file" | cut -f1) fi if (( bytes > 1000 )); then if [ -z "$total" ] || [[ "$total" == "0" ]] || [ "$bytes" -gt "$total" ]; then size=$(numfmt --to=iec --suffix=B "$bytes" | sed -r 's/([A-Z])/ \1/') Loading @@ -33,6 +39,7 @@ do fi echo "${body//(\[P\])/($size)}"> "$info" fi fi sleep 1 & wait $! done Loading
src/progress.sh +18 −11 Original line number Diff line number Diff line #!/usr/bin/env bash set -Eeuo pipefail info="/run/shm/msg.html" escape () { local s s=${1//&/\&} Loading @@ -14,16 +16,20 @@ escape () { file="$1" total="$2" body=$(escape "$3") info="/run/shm/msg.html" if [[ "$body" == *"..." ]]; then body="<p class=\"loading\">${body/.../}</p>" body="<p class=\"loading\">${body::-3}</p>" fi while true do if [ -s "$file" ]; then if [ ! -s "$file" ] && [ ! -d "$file" ]; then bytes="0" else bytes=$(du -sb "$file" | cut -f1) fi if (( bytes > 1000 )); then if [ -z "$total" ] || [[ "$total" == "0" ]] || [ "$bytes" -gt "$total" ]; then size=$(numfmt --to=iec --suffix=B "$bytes" | sed -r 's/([A-Z])/ \1/') Loading @@ -33,6 +39,7 @@ do fi echo "${body//(\[P\])/($size)}"> "$info" fi fi sleep 1 & wait $! done