Commits

Denilson Sá committed 54c1120

prettyping.sh: Fixing issue when "other_line" changes.

Like this:
http://pastebin.com/p9fwhTHi

Relevant (broken) output:
ping: sendto: No route to host
Last message repeated 9 times.Request timeout for icmp_seq 5
Request timeout for icmp_seq 6

Comments (0)

Files changed (1)

 	}
 }
 
+# Function called whenever the repeating line has changed.
+function other_line_finished_repeating() {
+	if( other_line_times >= 2 ) {
+		if( '"${IS_TERMINAL}"' ) {
+			printf( "\n" )
+		} else {
+			other_line_is_repeated()
+		}
+	}
+	other_line = ""
+	other_line_times = 0
+}
+
 # Prints the newlines required for the live statistics.
 #
 # I need to print some newlines and then return the cursor back to its position
 	# 64 bytes from 8.8.8.8: icmp_seq=1 ttl=49 time=184 ms
 	if( $0 ~ /^[0-9]+ bytes from .*: icmp_[rs]eq=[0-9]+ ttl=[0-9]+ time=[0-9.]+ *ms/ ) {
 		if( other_line_times >= 2 ) {
-			if( '"${IS_TERMINAL}"' ) {
-				printf( "\n" )
-			} else {
-				other_line_is_repeated()
-			}
+			other_line_finished_repeating()
 		}
-		other_line = ""
-		other_line_times = 0
 
 		# $1 = useless prefix string
 		# $2 = icmp_seq
 				other_line_is_repeated()
 			}
 		} else {
+			other_line_finished_repeating()
 			other_line = $0
 			other_line_times = 1
 			printf( "%s\n", $0 )