diff --git a/dobroho_vechora.bash b/dobroho_vechora.bash index 55474fe..b4726ae 100755 --- a/dobroho_vechora.bash +++ b/dobroho_vechora.bash @@ -73,6 +73,19 @@ print_messages() { close_socket } +wait_for_messages() { + oldlength="${length}" + while :; do + length="$(get_message 1)" + if [ "${oldlength}" -ne "${length}" ]; then + break + fi + echo -n . + sleep 1 + done + echo +} + length=0 while :; do read cmd @@ -101,17 +114,11 @@ while :; do echo "${length}" ;; w) - oldlength="${length}" - while :; do - length="$(get_message 1)" - if [ "${oldlength}" -ne "${length}" ]; then - break - fi - echo -n . - sleep 1 - done - echo + wait_for_messages print_messages "${length}" + if [ -n "${DOBROHO_VECHORA_ON_WAIT}" ]; then + ${DOBROHO_VECHORA_ON_WAIT} + fi ;; p) length="$(get_message 1)"