Allow interrupting "w".

This commit is contained in:
bʰedoh₂ swé 2025-01-12 05:05:09 +05:00
parent 6368aa3446
commit b064a0585b

View File

@ -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)"