Add error message if someone tries to use comma or other character instead of colon for LATLONG.

This commit is contained in:
me committed 2026-10-29 20:06:14 -07:00
1 parent 4aed123213
commit e1995dff80
1 file changed
+9 -4
+9 -4
View File
@@ -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