svn commit: r310179 - head/usr.sbin/portsnap/portsnap

Colin Percival cperciva at FreeBSD.org
Fri Dec 16 22:37:18 UTC 2016


Author: cperciva
Date: Fri Dec 16 22:37:16 2016
New Revision: 310179
URL: https://svnweb.freebsd.org/changeset/base/310179

Log:
  Avoid division by zero in the rare case that portsnap needs to fetch
  zero patches.  (This avoids two "dc: divide by zero" warnings.)
  
  MFC after:	3 days

Modified:
  head/usr.sbin/portsnap/portsnap/portsnap.sh

Modified: head/usr.sbin/portsnap/portsnap/portsnap.sh
==============================================================================
--- head/usr.sbin/portsnap/portsnap/portsnap.sh	Fri Dec 16 21:58:48 2016	(r310178)
+++ head/usr.sbin/portsnap/portsnap/portsnap.sh	Fri Dec 16 22:37:16 2016	(r310179)
@@ -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() {


More information about the svn-src-head mailing list