fix: correct argument parsing in create-new-feature.sh script#910
Merged
localden merged 2 commits intogithub:mainfrom Oct 19, 2025
Merged
fix: correct argument parsing in create-new-feature.sh script#910localden merged 2 commits intogithub:mainfrom
localden merged 2 commits intogithub:mainfrom
Conversation
Fix two critical bugs in the argument parsing logic that caused incorrect behavior when --short-name parameter was used: 1. **Index offset bug**: The loop started at i=0 and used i < $#, which incorrectly processed $0 (script name) as the first argument and skipped the last actual parameter. Changed to i=1 and i <= $# to properly iterate through actual command-line arguments ($1 to $#). 2. **Boundary condition bug**: The condition `[ $((i + 1)) -ge $# ]` incorrectly flagged valid arguments as missing. When --short-name was at position $#-1, the next position $# was valid but treated as out-of-bounds. Changed to `[ $((i + 1)) -gt $# ]` for correct validation. 3. **Enhanced validation**: Added check to ensure --short-name value is not another option (doesn't start with --). **Before**: - `script --json "desc" --short-name "test"` → Error: requires a value - `script --json "desc1" "desc2" --short-name` → Generated wrong branch name **After**: - `script --json "desc" --short-name "test"` → Works correctly - `script --json "desc1" "desc2" --short-name` → Proper error message This ensures the script correctly supports both parameter orders: - `[--json] [--short-name <name>] <feature_description>` - `[--json] <feature_description> [--short-name <name>]`
localden
previously approved these changes
Oct 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix two critical bugs in the argument parsing logic that caused incorrect behavior when --short-name parameter was used:
Index offset bug: The loop started at
i=0and usedi < $#, which incorrectly processed$0(script name) as the first argument and skipped the last actual parameter. Changed toi=1andi <= $#to properly iterate through actual command-line arguments ($1to$#).Boundary condition bug: The condition
[ $((i + 1)) -ge $# ]incorrectly flagged valid arguments as missing. When --short-name was at position$#-1, the next position $# was valid but treated as out-of-bounds. Changed to[ $((i + 1)) -gt $# ]for correct validation.Enhanced validation: Added check to ensure --short-name value is not another option (doesn't start with --).
Before:
script --json "desc" --short-name "test"→ Error: requires a valuescript --json "desc1" "desc2" --short-name→ Generated wrong branch nameAfter:
script --json "desc" --short-name "test"→ Works correctlyscript --json "desc1" "desc2" --short-name→ Proper error messageThis ensures the script correctly supports both parameter orders:
[--json] [--short-name <name>] <feature_description>[--json] <feature_description> [--short-name <name>]