How to make "dialog" progress bar increasing the counter, when each echo command is executed from function?
I have this code below as example, but I'm having problem of catching when command from function is executed. I can count number of "echo" in function and set as "items", but how to know when echo is finished and how to then increase the bar?
#!/bin/bash
function two() {
echo "test2-1"; sleep 1;
echo "test2-2"; sleep 1;
echo "test2-3"; sleep 1;
echo "test2-4"; sleep 1;
echo "test2-5"; sleep 1;
}
(
items=5
processed=0
while [ $processed -le $items ]; do
pct=$(( $processed * 100 / $items ))
echo "XXX"
echo "Processing item $processed" # Here I wish instead $processed
# to be value (test2-1, test2-2 etc.)
# of processed echo
echo "XXX"
echo "$pct"
processed=$((processed+1))
sleep 3 # Instead of this it should be when echo is finished printing
done
) | dialog --title "Gauge" --gauge "Wait please..." 10 60 0