Skip to content

ldd-detect, ldd-scope: a value-taking option given last is a usage error - #101

Open
buzzdan wants to merge 1 commit into
mainfrom
claude/option-value-guard
Open

buzzdan wants to merge 1 commit into
mainfrom
claude/option-value-guard

Conversation

@buzzdan

@buzzdan buzzdan commented Oct 18, 2026

Copy link
Copy Markdown
Owner

What

ldd-detect.sh and ldd-scope.sh looped forever when a value-taking option was the last argument. Two examples are ldd-detect.sh --root and ldd-scope.sh --out. The cause was shift 2, which fails without a shift when one argument is left. The argument loop then saw the same option again.

Both scripts now check for the value before the shift. A missing value stops the script with <option> needs a value and exit 2, the documented usage error.

Script Options with the check
ldd-detect.sh --files, --root, --rules, --cap, --glob, --test-re
ldd-scope.sh --root, --out, --max-lines, --glob, --test-re, --lang, --base

A Copilot review found the same bug in the gap linter on #100, and that PR fixes it there in the same way.

Changes

  • core/scripts/ldd-detect.sh and core/scripts/ldd-scope.sh: a value check before each shift 2.
  • Both test matrices get one case per option. Each case runs the script under a 5-second bound, so a regression fails the case and does not hang CI.
  • The four plugins are regenerated. Each changelog gets a Fixed entry under Unreleased.

Checks

  • task check, task lint-core and task docs:check pass.
  • ldd-detect_test.sh and ldd-scope_test.sh pass for all four plugins.
  • I ran the new cases against main's scripts, and all 13 fail.

🤖 Generated with Claude Code

When a value-taking option was the last argument, "shift 2" failed without
a shift, and the argument loop ran forever. Examples are
"ldd-detect.sh --root" and "ldd-scope.sh --out".

Both scripts now check for the value before the shift. A missing value
stops the script with "<option> needs a value" and exit 2, the documented
usage error. This covers ldd-detect's --files, --root, --rules, --cap,
--glob and --test-re, and ldd-scope's --root, --out, --max-lines, --glob,
--test-re, --lang and --base.

Each option has a matrix case that runs the script under a 5-second bound,
so a regression fails the case and does not hang CI. Every case fails on
the previous scripts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@buzzdan
buzzdan force-pushed the claude/option-value-guard branch from f3c3064 to f4b908b Compare October 18, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant