From 9226936571a510b6cc07bd3c9cdadf4572b44321 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Wed, 29 Sep 2021 05:03:06 -0700 Subject: [PATCH] check that interval is positive --- sh/minutemaid | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sh/minutemaid b/sh/minutemaid index 5be0f7a..76d7057 100755 --- a/sh/minutemaid +++ b/sh/minutemaid @@ -17,7 +17,8 @@ minutemaid() { ### @- ### ### note that `minutemaid 1` will always return 0, ### and `minutemaid 1 command` will always execute the command, - ### since every integer "minute" is evenly divisible by 1. + ### since every integral interval is evenly divisible by 1. + ### `minutemaid 0`, and any negative interval, is an error. ### ### ``` ### # crontab usage: @@ -45,6 +46,11 @@ minutemaid() { ### @- local interval="${1:?no interval specified}" shift + if [ "$interval" -le 0 ]; then + printf "%s\n" "$0: interval must be positive" >&2 + return 1 + fi + local sec="$(date +%s)" local min="$((sec/60+offset))" local mod="$((min%interval))"