From 3f68215d12c8addebd98a6b707eca82be5371091 Mon Sep 17 00:00:00 2001 From: Alessandro Caputo Date: Thu, 8 Aug 2019 01:18:44 +0200 Subject: [PATCH] notification: do not allow empty id with --ongoing Ongoing notifications can only be removed with termux-notification-remove, which requires the notification id. An ongoing notification without an id requires a reboot to be removed. This commit forbids creating such an "unremovable" notification. --- scripts/termux-notification | 6 ++++++ 1 file changed, 6 insertions(+) mode change 100644 => 100755 scripts/termux-notification diff --git a/scripts/termux-notification b/scripts/termux-notification old mode 100644 new mode 100755 index 6ad3358..fff6708 --- a/scripts/termux-notification +++ b/scripts/termux-notification @@ -114,6 +114,12 @@ done if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi +if [ "$OPT_ONGOING" == true ] && [ -z "$OPT_ID" ]; then + echo "Ongoing notifications without an ID are not removable." + echo "Please set an id with --id \"string\"." + exit 1 +fi + set -- if [ -n "$OPT_ACTION" ]; then set -- "$@" --es action "$OPT_ACTION"; fi if [ -n "$OPT_ALERT_ONCE" ]; then set -- "$@" --ez alert-once "$OPT_ALERT_ONCE"; fi