#!/bin/bash

s='0123456789ABCDEF'
t='\t\t'

i='\033[1;37;41m'
j='\033[m'
k='\033[K'

echo 'This assumes an 80-column terminal.'
echo 'It should be run at the bottom of the screen to witness the problem.'
echo 'All examples are a single line of content folded thrice to occupy 4 rows.'
echo 'This is with no protection whatsoever.'
echo -e "$s$s$s$s$i$s$s$j$s$t$s$i$s$s$j$s$s$s$i$s$s$j$s"
echo 'This is with the original and insufficient solution applied.'
echo -e "$s$s$s$s$i$s$s$j$s$t$s$i$s$s$j$s$s$s$i$s$s$j$k$s"
echo 'This is with the complete solution applied.'
echo -e "$s$s$s$s$i$s$s$j$k$s$t$s$i$s$s$j$k$s$s$s$i$s$s$j$k$s"
echo 'Pipe through "hexdump -C" to look at exact output characters.'
