diff options
Diffstat (limited to 'transport/dev-tcp.sh')
-rw-r--r-- | transport/dev-tcp.sh | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/transport/dev-tcp.sh b/transport/dev-tcp.sh index 9282880..49712b2 100644 --- a/transport/dev-tcp.sh +++ b/transport/dev-tcp.sh @@ -80,14 +80,37 @@ transport_alive() { # 0 If Ok # 1 If connection failed transport_read_line() { - read -ru 3 line - # Fail. - if [[ $? -ne 0 ]]; then - return 1 + while true + do + ze_length="$( wc -l '/tmp/un-provoked-message-store' 2> /dev/null )" + + if [[ -r /tmp/un-provoked-message-store ]] && + [[ -w /tmp/un-provoked-message-store ]] && (( ${ze_length%% *} )) + then + read -r line < /tmp/un-provoked-message-store + line=':tlCJ99mfZl!~user@2001:ba8:1f1:f216::5 PRIVMSG #hyperbola :'"${line}" + + # remove the top line of the file + if (( ${ze_length%% *} < 2 )) + then + echo -n > /tmp/un-provoked-message-store + else + tail -n +2 /tmp/un-provoked-message-store | + sponge /tmp/un-provoked-message-store + fi + + break else - time_get_current 'transport_lastvalidtime' + read -t 5 -ru 3 line + the_return_code="${?}" + (( the_return_code == 0 )) && break + (( the_return_code > 128 )) && continue + [[ "${the_return_code}" -ne 0 ]] && return fi - line=${line//$'\r'/} + done + + time_get_current 'transport_lastvalidtime' + line=${line//$'\r'/} } # Send a line |