framework tools/git: guards reject all option-shaped values; usage_error routes usage to stderr (codex round on PR #1464)
ci/woodpecker/pr/ci Pipeline is pending
ci/woodpecker/pr/ci Pipeline is pending
- Option-like value = any token starting with '-' followed by an alphanumeric (-h, -ab, --help); multi-character short clusters were still accepted (codex blocker). Bare '-' is reserved (future stdin). - usage_error now prints the usage text to stderr as well (codex should-fix): usage output belonged to stdout only on the help path. - 16/16 usage-contract suites green.
This commit is contained in:
@@ -24,14 +24,14 @@ usage_error() {
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-i|--issue)
|
||||
[[ $# -ge 2 && "$2" != --* && ! "$2" =~ ^-[a-zA-Z]$ ]] || usage_error "option $1 requires a value (option-like values are rejected)"
|
||||
[[ $# -ge 2 && "$2" != - && "$2" != --* && ! "$2" =~ ^-[[:alnum:]] ]] || usage_error "option $1 requires a value (option-like values are rejected; bare - is reserved)"
|
||||
ISSUE_NUMBER="$2"
|
||||
shift 2
|
||||
;;
|
||||
-b|--body|-c|--comment)
|
||||
# R1 (2026-08-28): --body is the canonical flag; -c/--comment stays
|
||||
# a backward-compatible alias.
|
||||
[[ $# -ge 2 && "$2" != --* && ! "$2" =~ ^-[a-zA-Z]$ ]] || usage_error "option $1 requires a value (option-like values are rejected)"
|
||||
[[ $# -ge 2 && "$2" != - && "$2" != --* && ! "$2" =~ ^-[[:alnum:]] ]] || usage_error "option $1 requires a value (option-like values are rejected; bare - is reserved)"
|
||||
COMMENT="$2"
|
||||
shift 2
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user