xref: /freebsd/contrib/bsddialog/examples_utility/gauge.sh (revision 963f5dc7a30624e95d72fb7f87b8892651164e46)
1#!/bin/sh
2#-
3# SPDX-License-Identifier: CC0-1.0
4#
5# Written in 2021 by Alfonso Sabato Siciliano.
6# To the extent possible under law, the author has dedicated all copyright
7# and related and neighboring rights to this software to the public domain
8# worldwide. This software is distributed without any warranty, see:
9# <http://creativecommons.org/publicdomain/zero/1.0/>.
10
11input="A B C D E F G"
12total=`echo $input | awk '{print split($0, a)}'`
13curr=1
14for i in $input
15do
16	sleep 1
17        perc="$(expr $(expr $curr "*" 100 ) "/" $total )"
18        echo XXX
19        echo $perc
20        echo "[$curr/$total] Input: $i"
21        echo XXX
22        if [ $curr -eq $total ]
23        then
24                echo EOF
25        fi
26        curr=`expr $curr + 1`
27done | ./bsddialog --title gauge --gauge "[0/$total] Starting..." 10 70 0
28
29