Properly handle 'All caught up!' output from gh-notify

This commit is contained in:
ItsDrike 2023-01-25 12:50:30 +01:00
parent ed1487a251
commit f8f96d4dd7
No known key found for this signature in database
GPG key ID: B014E761034AF742

View file

@ -190,6 +190,12 @@ send_notify() {
# Request unread notifications with gh-notify extension for github-cli
[ "$ALL" -eq 1 ] && out="$(gh notify -s -a -n "$MAX_AMOUNT")" || out="$(gh notify -s -n "$MAX_AMOUNT")"
# When no notifications were found, set output to empty string, to avoid 'All caught up!' line
# being treated as notification
if [ "$out" == "All caught up!" ]; then
out=""
fi
total="$(printf "%s\n" "$out" | wc -l)"
# Since we always end with a newline (to count the last entry as a line), we always get
# at least 1 as a total here, even if $out is empty. If we didn't use the \n, we'd always