summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoritz Luedecke2016-08-30 10:14:00 +0200
committerMoritz Luedecke2016-08-30 10:14:00 +0200
commite6602a3f222e5bca5f994dd3d6c89000a48a2f65 (patch)
tree712081e53f3b302ed4da6ca647ad821a9d9dd066
parentc031344f365f43c06268b9dc941cb24130ca8c5f (diff)
downloadaur-pbar.tar.gz
Repair package
-rw-r--r--.SRCINFO2
-rwxr-xr-xpbar229
2 files changed, 1 insertions, 230 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 10adfa091cfb..668631236be9 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,6 +1,6 @@
pkgbase = pbar
pkgdesc = Progress bar in pacman style
- pkgver = 20150414
+ pkgver = 20160830
pkgrel = 1
url = https://github.com/ritze/pbar
arch = any
diff --git a/pbar b/pbar
deleted file mode 100755
index 48a31f8efdfa..000000000000
--- a/pbar
+++ /dev/null
@@ -1,229 +0,0 @@
-#!/bin/bash
-# Copyright Matthew Bruenig <matthewbruenig@gmail.com> (packer)
-# Moritz Lüdecke <ritze@skweez.net>
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-DASH="-"
-HASH="#"
-BEGINBAR="["
-ENDBAR="]"
-INFBAR_UPDATE="0.1"
-
-usage() {
- echo 'usage: pbar [OPTION] [-t DEVICE] DONE TOTAL [TITLE] [DETAILS]...'
- echo
- echo ' -i infinite progressbar,'
- echo ' -n outputs a new line at the end'
- echo ' -t set the tty device'
- echo ' -h display this help and exit'
- echo
- echo 'Examples:'
- echo ' pbar -n 3 5 "testing..." 3 of 5 Print the follow line:'
- echo 'testing... 3 of 5 [##########--------] 60%'
- echo ' pbar -i 0 0 "testing..." Print a infinite working progressbar:'
- echo 'testing... [------###---------]'
- exit
-}
-
-screenwidth() {
- local tty=$1
- local width="$(stty -F $tty size)"
- echo "${width##* }"
-}
-
-removeformat() {
- echo "$(echo -e "$1" | sed 's/\x1b\[[0-9;]*[m|K]//g')"
-}
-
-info() {
- local width=$1
- local title=$2
- local misc=$3
-
- # Get vars for output
- local beginline=$title
- local misclen=0
- # Remove color code
- if [[ $misc != "" ]]; then
- local misctext=$(removeformat "$misc")
- misclen=$((1+${#misctext}))
- fi
- local beginlinetext=$(removeformat "$beginline")
- if [[ $width -lt $((${#beginlinetext}+2+$misclen-1)) ]]; then
- # Remove color code, cut the text and print it without color code
- beginlinetext=${beginlinetext::$((width-$misclen-4))}
- beginline=$beginlinetext"..."
- beginlinetext=$(removeformat "$beginline")
- fi
- local spaces="$(($width-${#beginlinetext}-1-$misclen))"
-
- # Print output
- printf "$beginline %${spaces}s"
- [[ $misc != "" ]] && printf " $misc"
-}
-
-drawsymbol() {
- local symbol=$1
- local num=$2
-
- for ((n=0; n<$num; n++)); do
- printf "$symbol"
- done
-}
-
-# This method is a fork from the packer method aurbar
-progbar() {
- local width=$1
- local infinite=$2
- local done=$3
- local total=$4
-
- # Get vars for output
- local barchars="$(($width-${#BEGINBAR}-${#ENDBAR}-6))"
- local hashes="$(($barchars*$done/$total))"
- local dashes="$(($barchars-$hashes))"
-
- # Print output
- printf " ${BEGINBAR}"
-
- if [[ $infinite ]]; then
- local offset="$(($hashes-2))"
- hashes=3
- [[ $offset -lt 0 ]] && offset=0 && hashes=2
- drawsymbol $DASH $offset
-
- offset="$(($offset+$hashes))"
- [[ $offset -gt $barchars ]] && hashes=2
- drawsymbol $HASH $hashes
-
- dashes="$(($barchars-$offset))"
- drawsymbol $DASH $dashes
- printf "%s \r" ${ENDBAR}
- else
- drawsymbol $HASH $hashes
- drawsymbol $DASH $dashes
- local perc="$(($done*100/$total))"
- printf "%s%4s%%\r" ${ENDBAR} ${perc}
- fi
-}
-
-printline() {
- local tty=$1
- local infinite=$2
- local done=$3
- local total=$4
- local title=$5
- local misc=$6
-
- local width=$(screenwidth $tty)
- local infolen="$(($width*6/10))"
- [ $width -lt 50 ] && width=50
- local progbarlen="$(($width-$infolen))"
-
- if [[ $total -eq 0 ]]; then
- total=$(($progbarlen-9))
-
- local newdone="$(($done % $total))"
- if [[ $(($done % $((2*$total)))) -ge $total ]]; then
- newdone="$(($total-$newdone))"
- fi
- done=$(($newdone+1))
- total=$(($total+1))
- fi
-
- # Delete line
- printf "\033[0G"
-
- info $infolen "$title" "$misc"
- progbar $progbarlen "$infinite" $done $total
-}
-
-# Argument parsing
-
-[[ $1 ]] || usage
-
-while getopts ":hint:" optname; do
- case "$optname" in
- "i")
- infinite=1
- ;;
- "n")
- newline=1
- ;;
- "t")
- tty=$OPTARG
- ;;
- "h")
- usage
- ;;
- "?")
- echo "Unknown option $OPTARG"
- usage
- ;;
- ":")
- echo "No argument value for option $OPTARG"
- ;;
- *)
- echo "Unknown error while processing options"
- ;;
- esac
-done
-
-done=${@:$OPTIND:1}
-total=${@:$OPTIND+1:1}
-title="${@:$OPTIND+2:1}"
-misc="${@:$OPTIND+3}"
-
-int='^[0-9]+$'
-
-if [[ $tty == "" ]]; then
- tty=$(tty)
- if [[ $? -ne 0 ]]; then
- echo "Can't get tty device!"
- usage
- fi
-fi
-
-if [[ $total -eq "" ]] ||
- ! [[ $done =~ $int ]] || ! [[ $total =~ $int ]]; then
-
- if [[ $done -ne 0 ]] || [[ $total -ne 0 ]] || [[ $infinite -ne 1 ]]; then
- usage
- fi
-fi
-
-if [[ $done -gt $total ]]; then
- done=$total
-fi
-
-if [[ $done -eq 0 ]] && [[ $total -eq 0 ]] && [[ $infinite -eq 1 ]]; then
- trap "exit=true" SIGINT SIGTERM
- i=0
- while [ ! $exit ]; do
- printline $tty "$infinite" $i 0 "$title" "$misc"
- i="$(($i+1))"
- sleep $INFBAR_UPDATE
- done
-
- # Delete line
- printf "\033[0G"
-
- [ $newline ] && printline $tty "" 1 1 "$title" "$misc"
-else
- printline $tty "$infinite" $done $total "$title" "$misc"
-fi
-
-[ $newline ] && echo
-
-exit