From 40c72f61731a80491d2e55162aa43fa321abc94c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Dec 2025 22:45:32 +0000 Subject: [PATCH 1/2] Initial plan From 484601f67e8acd4b16bd4872c720c0f888af76d3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Dec 2025 22:48:39 +0000 Subject: [PATCH 2/2] Make zparseopts section extraction more robust Use last element instead of hardcoded index 2, add validation for array length, and provide clear error message when --section value is missing. Co-authored-by: bgreg <3711139+bgreg@users.noreply.github.com> --- goodmorning.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/goodmorning.sh b/goodmorning.sh index 2e61dd7..f110b4b 100755 --- a/goodmorning.sh +++ b/goodmorning.sh @@ -287,7 +287,13 @@ main() { # Handle single section mode (skip all preflight and run just one function) if [[ ${#section_arg[@]} -gt 0 ]]; then - local section_name="${section_arg[2]}" + # zparseopts stores option name at index 1 and value at index 2 + # Use the last element to be more robust against zparseopts behavior changes + if [[ ${#section_arg[@]} -lt 2 ]]; then + echo "Error: --section requires a value" >&2 + return 1 + fi + local section_name="${section_arg[-1]}" _run_single_section "$section_name" return $? fi