From a3156aa8a17cb7e0909ef146c0400b7d39f1b211 Mon Sep 17 00:00:00 2001 From: cperciva Date: Mon, 19 Dec 2016 07:46:20 +0000 Subject: MFC r310179: Avoid division by zero in the rare case that portsnap needs to fetch zero patches. (This avoids two "dc: divide by zero" warnings.) --- usr.sbin/portsnap/portsnap/portsnap.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'usr.sbin/portsnap') diff --git a/usr.sbin/portsnap/portsnap/portsnap.sh b/usr.sbin/portsnap/portsnap/portsnap.sh index 0e16370..dd33ee3 100644 --- a/usr.sbin/portsnap/portsnap/portsnap.sh +++ b/usr.sbin/portsnap/portsnap/portsnap.sh @@ -619,8 +619,10 @@ fetch_progress() { pct_fmt() { - printf " \r" - printf "($1/$2) %02.2f%% " `echo "scale=4;$LNC / $TOTAL * 100"|bc` + if [ $TOTAL -gt 0 ]; then + printf " \r" + printf "($1/$2) %02.2f%% " `echo "scale=4;$LNC / $TOTAL * 100"|bc` + fi } fetch_progress_percent() { -- cgit v1.1