From d53c44cc768e0fe11bf5af98950be7451ea4c6a0 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Mon, 27 Oct 2025 15:14:14 -0400 Subject: [PATCH] Fix parsing for real this time. --- modules/weather/weather.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/weather/weather.sh b/modules/weather/weather.sh index 9c366d5..10d4077 100755 --- a/modules/weather/weather.sh +++ b/modules/weather/weather.sh @@ -15,6 +15,12 @@ name="$1" channelName="$2" shift 2 +# Parse arguments into array to handle subcommands properly +# When bot.sh calls this with "$will", it arrives as a single quoted argument +# e.g., "set Ferguson North Carolina" comes as one $1, not multiple args +# shellcheck disable=SC2206 +request=($*) + # Database file for user locations and cached geocoding weatherDb="data/weather.db" weatherDbLock="${weatherDb}.lock" @@ -453,18 +459,20 @@ format_forecast() { } # Main command logic -subcommand="${1:-}" +# Check if first element is a subcommand +subcommand="${request[0]:-}" case "$subcommand" in set) # Set user's location - shift - if [[ $# -eq 0 ]]; then + # Remove 'set' from the array and get the rest as location + if [[ ${#request[@]} -lt 2 ]]; then msg "$channelName" "$name: Usage: weather set " exit 0 fi - location="$*" + # Get everything after 'set' as the location + location="${request[*]:1}" # Validate location length if [[ ${#location} -gt 100 ]]; then @@ -502,7 +510,7 @@ case "$subcommand" in # Show weather (default action) if [[ -n "$subcommand" ]]; then # Weather for specified location - location="$*" + location="${request[*]}" # Validate location length if [[ ${#location} -gt 100 ]]; then