diff --git a/sunset-alarm b/sunset-alarm index cec4bd4..ffcd222 100755 --- a/sunset-alarm +++ b/sunset-alarm @@ -32,18 +32,23 @@ while [ $# -gt 0 ]; do -m) MINUTES="$2"; shift 2 ;; -h) usage ;; --) shift; break ;; - *) echo "Error: unknown argument '$1'" >&2; usage ;; + *) echo "ERROR: unknown argument '$1'" >&2; usage ;; esac done # Validate inputs if [ -z "$MINUTES" ]; then - echo "Error: -m MINUTES is required." >&2 + echo "ERROR: -m MINUTES is required." >&2 usage fi if [ -z "$LATLONG" ] && [ -z "$SUNSET_TIME" ]; then - echo "Error: must specify either -l LAT:LONG or -t HH:MI." >&2 + echo "ERROR: must specify either -l LAT:LONG or -t HH:MI." >&2 + usage +fi + +if [[ -n "$LATLONG" && "$LATLONG" != *":"* ]]; then + echo "ERROR: LAT:LONG is missing the colon." >&2 usage fi @@ -146,7 +151,7 @@ while true; do SUNSET_EPOCH=$(date -d "${TODAY} ${SUNSET_TIME}" +%s 2>/dev/null) if [ -z "$SUNSET_EPOCH" ]; then - echo "Error: could not parse time '${SUNSET_TIME}'." >&2 + echo "ERROR: could not parse time '${SUNSET_TIME}'." >&2 sleep 60 continue fi