Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions prettyping
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ function get_terminal_size(SIZE, SIZEA, HAS_DETECTED, CMD) {
HAS_DETECTED = 0

CMD = "stty -f /dev/tty size 2> /dev/null"

if ( (CMD | getline SIZE) == 1 ) {
split(SIZE, SIZEA, " ")
LINES = int(SIZEA[1])
Expand All @@ -270,21 +269,32 @@ function get_terminal_size(SIZE, SIZEA, HAS_DETECTED, CMD) {
close(CMD)

if ( HAS_DETECTED == 0 ) {
CMD = "tput lines"
CMD = "tput lines 2> /dev/null"
if ( (CMD | getline SIZE) == 1 ) {
LINES = int(SIZE)
HAS_DETECTED = 1
}
close(CMD)

CMD = "tput cols"
CMD = "tput cols 2> /dev/null"
if ( (CMD | getline SIZE) == 1 ) {
COLUMNS = int(SIZE)
HAS_DETECTED = 1
}
close(CMD)
}

if ( HAS_DETECTED == 0 ) {
CMD = "bash -i -c \"echo \\$LINES \\$COLUMNS\" 2> /dev/null"
while ( (CMD | getline SIZE) == 1) {
split(SIZE, SIZEA, " ")
LINES = int(SIZEA[1])
COLUMNS = int(SIZEA[2])
HAS_DETECTED = 1
}
close(CMD)
}

if ( int('"${OVERRIDE_COLUMNS}"') ) { COLUMNS = int('"${OVERRIDE_COLUMNS}"') }
if ( int('"${OVERRIDE_LINES}"') ) { LINES = int('"${OVERRIDE_LINES}"') }
}
Expand Down Expand Up @@ -766,7 +776,7 @@ BEGIN {
############################################################
# Main loop
{
if ( $0 ~ /^[0-9]+ bytes from .*[:,] icmp_[rs]eq=[0-9]+ (ttl|hlim)=[0-9]+ time=[0-9.]+ *ms/ ) {
if ( $0 ~ /^[0-9]+ bytes from .*[:,] (icmp_)?[rs]eq=[0-9]+ (ttl|hlim)=[0-9]+ time=[0-9.]+ *ms/ ) {
# Sample line from ping:
# 64 bytes from 8.8.8.8: icmp_seq=1 ttl=49 time=184 ms
if ( other_line_times >= 2 ) {
Expand Down