2
0
Fork 0

sh.zio.backup: handle empty message in notification

main
Ducky 2024-04-02 00:12:52 +01:00
parent 41c730e999
commit a06ebcb217
1 changed files with 12 additions and 8 deletions

View File

@ -157,18 +157,22 @@ function trigger_notify() {
notify_prog="/usr/local/bin/sh.zio.notify"
if [[ $log_path == "" ]]; then
log_path="$message"
message=""
if [[ -f "$message" ]]; then
log_path="$message"
message=""
fi
fi
if [[ ! -f "$notify_prog" ]]; then
say warning "'$notify_prog' not found. Not sending notification"
say warning "'$notify_prog' does not exist. Not sending notification"
else
"$notify_prog" \
--file "$log_path" \
--level "$level" \
--message '\\`\\`\\`\\n'"${message//$'\n'/'\\n'}"'\\n\\`\\`\\`' \
--title "$title"
notify_command="$notify_prog"
[[ -n "$log_path" ]] && notify_command+=" --file \"$log_path\""
[[ -n "$message" ]] && notify_command+=" --message '\\`\\`\\`\\n'"${message//$'\n'/'\\n'}"'\\n\\`\\`\\`'"
notify_command+=" --level $level"
notify_command+=" --title \"$title\""
eval $notify_command
fi
}