diff --git a/usr/local/bin/sh.zio.backup b/usr/local/bin/sh.zio.backup index 51b906f..77718b6 100755 --- a/usr/local/bin/sh.zio.backup +++ b/usr/local/bin/sh.zio.backup @@ -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 }