diff --git a/dobroho_vechora.bash b/dobroho_vechora.bash index c6329ea..beca268 100755 --- a/dobroho_vechora.bash +++ b/dobroho_vechora.bash @@ -70,16 +70,22 @@ print_messages() { } wait_for_messages() { + tmp=0 + trap 'tmp=1' INT oldlength="${length}" while :; do length="$(get_message 1)" if [ "${oldlength}" -ne "${length}" ]; then - break + trap - INT + return 0 + fi + if [ "${tmp}" -eq 1 ]; then + trap - INT + return 1 fi echo -n . sleep 1 done - echo } length=0 @@ -103,11 +109,14 @@ while :; do echo "${length}" ;; w) - wait_for_messages - print_messages "${length}" - if [ -n "${DOBROHO_VECHORA_ON_WAIT}" ]; then - ${DOBROHO_VECHORA_ON_WAIT} - fi + wait_for_messages && + { + echo + print_messages "${length}" + if [ -n "${DOBROHO_VECHORA_ON_WAIT}" ]; then + ${DOBROHO_VECHORA_ON_WAIT} + fi + } ;; p) length="$(get_message 1)"